home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / mysql-4.0.22-win / data1.cab / Documentation / Docs / manual.txt < prev    next >
Encoding:
Text File  |  2004-10-28  |  3.8 MB  |  96,485 lines

Text Truncated. Only the first 1MB is shown below. Download the file for the complete contents.
  1. START-INFO-DIR-ENTRY
  2. * mysql: (mysql).               MySQL documentation.
  3. END-INFO-DIR-ENTRY
  4.  
  5. Table of Contents
  6. *****************
  7.  
  8.  
  9. General Information
  10.   About This Manual
  11.     Conventions Used in This Manual
  12.   Overview of the MySQL Database Management System
  13.     History of MySQL
  14.     The Main Features of MySQL
  15.     MySQL Stability
  16.     How Big MySQL Tables Can Be
  17.     Year 2000 Compliance
  18.   Overview of MySQL AB
  19.     The Business Model and Services of MySQL AB
  20.       Support
  21.       Training and Certification
  22.       Consulting
  23.       Commercial Licenses
  24.       Partnering
  25.     Contact Information
  26.   MySQL Support and Licensing
  27.     Support Offered by MySQL AB
  28.     Copyrights and Licenses Used by MySQL
  29.     MySQL Licenses
  30.       Using the MySQL Software Under a Commercial License
  31.       Using the MySQL Software for Free Under GPL
  32.     MySQL AB Logos and Trademarks
  33.       The Original MySQL Logo
  34.       MySQL Logos That May Be Used Without Written Permission
  35.       When You Need Written Permission to Use MySQL Logos
  36.       MySQL AB Partnership Logos
  37.       Using the Word MySQL in Printed Text or Presentations
  38.       Using the Word MySQL in Company and Product Names
  39.   MySQL Development Roadmap
  40.     MySQL 4.0 in a Nutshell
  41.       Features Available in MySQL 4.0
  42.       The Embedded MySQL Server
  43.     MySQL 4.1 in a Nutshell
  44.       Features Available in MySQL 4.1
  45.       Stepwise Rollout
  46.       Ready for Immediate Development Use
  47.     MySQL 5.0: The Next Development Release
  48.   MySQL and the Future (the TODO)
  49.     New Features Planned for 5.0
  50.     New Features Planned for 5.1
  51.     New Features Planned for the Near Future
  52.     New Features Planned for the Mid-Term Future
  53.     New Features We Don't Plan to Implement
  54.   MySQL Information Sources
  55.     MySQL Mailing Lists
  56.       The MySQL Mailing Lists
  57.       Asking Questions or Reporting Bugs
  58.       How to Report Bugs or Problems
  59.       Guidelines for Answering Questions on the Mailing List
  60.     MySQL Community Support on IRC (Internet Relay Chat)
  61.   MySQL Standards Compliance
  62.     What Standards MySQL Follows
  63.     Selecting SQL Modes
  64.     Running MySQL in ANSI Mode
  65.     MySQL Extensions to Standard SQL
  66.     MySQL Differences from Standard SQL
  67.       Subqueries
  68.       `SELECT INTO TABLE'
  69.       Transactions and Atomic Operations
  70.       Stored Procedures and Triggers
  71.       Foreign Keys
  72.       Views
  73.       `--' as the Start of a Comment
  74.     How MySQL Deals with Constraints
  75.       `PRIMARY KEY' and `UNIQUE' Index Constraints
  76.       Constraints on Invalid Data
  77.       `ENUM' and `SET' Constraints
  78.     Known Errors and Design Deficiencies in MySQL
  79.       Errors in 3.23 Fixed in a Later MySQL Version
  80.       Errors in 4.0 Fixed in a Later MySQL Version
  81.       Open Bugs and Design Deficiencies in MySQL
  82.  
  83. Installing MySQL
  84.   General Installation Issues
  85.     Operating Systems Supported by MySQL
  86.     Choosing Which MySQL Distribution to Install
  87.       Choosing Which Version of MySQL to Install
  88.       Choosing a Distribution Format
  89.       How and When Updates Are Released
  90.       Release Philosophy--No Known Bugs in Releases
  91.       MySQL Binaries Compiled by MySQL AB
  92.     How to Get MySQL
  93.     Verifying Package Integrity Using MD5 Checksums or `GnuPG'
  94.       Verifying the MD5 Checksum
  95.       Signature Checking Using `GnuPG'
  96.       Signature Checking Using `RPM'
  97.     Installation Layouts
  98.   Standard MySQL Installation Using a Binary Distribution
  99.     Installing MySQL on Windows
  100.       Windows System Requirements
  101.       Installing a Windows Binary Distribution
  102.       Preparing the Windows MySQL Environment
  103.       Selecting a Windows Server
  104.       Starting the Server for the First Time
  105.       Starting MySQL from the Windows Command Line
  106.       Starting MySQL as a Windows Service
  107.       Troubleshooting a MySQL Installation Under Windows
  108.       Running MySQL Client Programs on Windows
  109.       MySQL on Windows Compared to MySQL on Unix
  110.     Installing MySQL on Linux
  111.     Installing MySQL on Mac OS X
  112.     Installing MySQL on NetWare
  113.     Installing MySQL on Other Unix-Like Systems
  114.   MySQL Installation Using a Source Distribution
  115.     Source Installation Overview
  116.     Typical `configure' Options
  117.     Installing from the Development Source Tree
  118.     Dealing with Problems Compiling MySQL
  119.     MIT-pthreads Notes
  120.     Installing MySQL from Source on Windows
  121.       Building MySQL Using VC++
  122.       Creating a Windows Source Package from the Latest Development Source
  123.     Compiling MySQL Clients on Windows
  124.   Post-Installation Setup and Testing
  125.     Windows Post-Installation Procedures
  126.     Unix Post-Installation Procedures
  127.       Problems Running `mysql_install_db'
  128.       Starting and Stopping MySQL Automatically
  129.       Starting and Troubleshooting the MySQL Server
  130.     Securing the Initial MySQL Accounts
  131.   Upgrading/Downgrading MySQL
  132.     Upgrading from Version 4.1 to 5.0
  133.     Upgrading from Version 4.0 to 4.1
  134.     Upgrading from Version 3.23 to 4.0
  135.     Upgrading from Version 3.22 to 3.23
  136.     Upgrading from Version 3.21 to 3.22
  137.     Upgrading from Version 3.20 to 3.21
  138.     Upgrading MySQL Under Windows
  139.     Upgrading the Grant Tables
  140.     Copying MySQL Databases to Another Machine
  141.   Operating System-Specific Notes
  142.     Linux Notes
  143.       Linux Operating System Notes
  144.       Linux Binary Distribution Notes
  145.       Linux Source Distribution Notes
  146.       Linux Post-Installation Notes
  147.       Linux x86 Notes
  148.       Linux SPARC Notes
  149.       Linux Alpha Notes
  150.       Linux PowerPC Notes
  151.       Linux MIPS Notes
  152.       Linux IA-64 Notes
  153.     Mac OS X Notes
  154.       Mac OS X 10.x (Darwin)
  155.       Mac OS X Server 1.2 (Rhapsody)
  156.     Solaris Notes
  157.       Solaris 2.7/2.8 Notes
  158.       Solaris x86 Notes
  159.     BSD Notes
  160.       FreeBSD Notes
  161.       NetBSD Notes
  162.       OpenBSD 2.5 Notes
  163.       OpenBSD 2.8 Notes
  164.       BSD/OS Version 2.x Notes
  165.       BSD/OS Version 3.x Notes
  166.       BSD/OS Version 4.x Notes
  167.     Other Unix Notes
  168.       HP-UX Version 10.20 Notes
  169.       HP-UX Version 11.x Notes
  170.       IBM-AIX notes
  171.       SunOS 4 Notes
  172.       Alpha-DEC-UNIX Notes (Tru64)
  173.       Alpha-DEC-OSF/1 Notes
  174.       SGI Irix Notes
  175.       SCO Notes
  176.       SCO UnixWare Version 7.1.x Notes
  177.     OS/2 Notes
  178.     BeOS Notes
  179.   Perl Installation Notes
  180.     Installing Perl on Unix
  181.     Installing ActiveState Perl on Windows
  182.     Problems Using the Perl `DBI'/`DBD' Interface
  183.  
  184. MySQL Tutorial
  185.   Connecting to and Disconnecting from the Server
  186.   Entering Queries
  187.   Creating and Using a Database
  188.     Creating and Selecting a Database
  189.     Creating a Table
  190.     Loading Data into a Table
  191.     Retrieving Information from a Table
  192.       Selecting All Data
  193.       Selecting Particular Rows
  194.       Selecting Particular Columns
  195.       Sorting Rows
  196.       Date Calculations
  197.       Working with `NULL' Values
  198.       Pattern Matching
  199.       Counting Rows
  200.       Using More Than one Table
  201.   Getting Information About Databases and Tables
  202.   Using `mysql' in Batch Mode
  203.   Examples of Common Queries
  204.     The Maximum Value for a Column
  205.     The Row Holding the Maximum of a Certain Column
  206.     Maximum of Column per Group
  207.     The Rows Holding the Group-wise Maximum of a Certain Field
  208.     Using User Variables
  209.     Using Foreign Keys
  210.     Searching on Two Keys
  211.     Calculating Visits Per Day
  212.     Using `AUTO_INCREMENT'
  213.   Queries from the Twin Project
  214.     Find All Non-distributed Twins
  215.     Show a Table of Twin Pair Status
  216.   Using MySQL with Apache
  217.  
  218. Using MySQL Programs
  219.   Overview of MySQL Programs
  220.   Invoking MySQL Programs
  221.   Specifying Program Options
  222.     Using Options on the Command Line
  223.     Using Option Files
  224.     Using Environment Variables to Specify Options
  225.     Using Options to Set Program Variables
  226.  
  227. Database Administration
  228.   The MySQL Server and Server Startup Scripts
  229.     Overview of the Server-Side Scripts and Utilities
  230.     The `mysqld-max' Extended MySQL Server
  231.     The `mysqld_safe' Server Startup Script
  232.     The `mysql.server' Server Startup Script
  233.     The `mysqld_multi' Program for Managing Multiple MySQL Servers
  234.   Configuring the MySQL Server
  235.     `mysqld' Command-Line Options
  236.     The Server SQL Mode
  237.     Server System Variables
  238.       Dynamic System Variables
  239.     Server Status Variables
  240.   The MySQL Server Shutdown Process
  241.   General Security Issues
  242.     General Security Guidelines
  243.     Making MySQL Secure Against Attackers
  244.     Startup Options for `mysqld' Concerning Security
  245.     Security Issues with `LOAD DATA LOCAL'
  246.   The MySQL Access Privilege System
  247.     What the Privilege System Does
  248.     How the Privilege System Works
  249.     Privileges Provided by MySQL
  250.     Connecting to the MySQL Server
  251.     Access Control, Stage 1: Connection Verification
  252.     Access Control, Stage 2: Request Verification
  253.     When Privilege Changes Take Effect
  254.     Causes of `Access denied' Errors
  255.     Password Hashing in MySQL 4.1
  256.       Implications of Password Hashing Changes for Application Programs
  257.       Password Hashing in MySQL 4.1.0
  258.   MySQL User Account Management
  259.     MySQL Usernames and Passwords
  260.     Adding New User Accounts to MySQL
  261.     Removing User Accounts from MySQL
  262.     Limiting Account Resources
  263.     Assigning Account Passwords
  264.     Keeping Your Password Secure
  265.     Using Secure Connections
  266.       Basic SSL Concepts
  267.       Requirements
  268.       Setting Up SSL Certificates for MySQL
  269.       SSL `GRANT' Options
  270.       SSL Command-Line Options
  271.       Connecting to MySQL Remotely from Windows with SSH
  272.   Disaster Prevention and Recovery
  273.     Database Backups
  274.     Table Maintenance and Crash Recovery
  275.       `myisamchk' Invocation Syntax
  276.       General Options for `myisamchk'
  277.       Check Options for `myisamchk'
  278.       Repair Options for `myisamchk'
  279.       Other Options for `myisamchk'
  280.       `myisamchk' Memory Usage
  281.       Using `myisamchk' for Crash Recovery
  282.       How to Check `MyISAM' Tables for Errors
  283.       How to Repair Tables
  284.       Table Optimization
  285.     Setting Up a Table Maintenance Schedule
  286.     Getting Information About a Table
  287.   MySQL Localization and International Usage
  288.     The Character Set Used for Data and Sorting
  289.       Using the German Character Set
  290.     Setting the Error Message Language
  291.     Adding a New Character Set
  292.     The Character Definition Arrays
  293.     String Collating Support
  294.     Multi-Byte Character Support
  295.     Problems With Character Sets
  296.     MySQL Server Time Zone Support
  297.   The MySQL Log Files
  298.     The Error Log
  299.     The General Query Log
  300.     The Update Log
  301.     The Binary Log
  302.     The Slow Query Log
  303.     Log File Maintenance
  304.   Running Multiple MySQL Servers on the Same Machine
  305.     Running Multiple Servers on Windows
  306.       Starting Multiple Windows Servers at the Command Line
  307.       Starting Multiple Windows Servers as Services
  308.     Running Multiple Servers on Unix
  309.     Using Client Programs in a Multiple-Server Environment
  310.   The MySQL Query Cache
  311.     How the Query Cache Operates
  312.     Query Cache `SELECT' Options
  313.     Query Cache Configuration
  314.     Query Cache Status and Maintenance
  315.  
  316. Replication in MySQL
  317.   Introduction to Replication
  318.   Replication Implementation Overview
  319.   Replication Implementation Details
  320.     Replication Master Thread States
  321.     Replication Slave I/O Thread States
  322.     Replication Slave SQL Thread States
  323.     Replication Relay and Status Files
  324.   How to Set Up Replication
  325.   Replication Compatibility Between MySQL Versions
  326.   Upgrading a Replication Setup
  327.     Upgrading Replication to 4.0 or 4.1
  328.     Upgrading Replication to 5.0
  329.   Replication Features and Known Problems
  330.   Replication Startup Options
  331.   Replication FAQ
  332.   Troubleshooting Replication
  333.   Reporting Replication Bugs
  334.  
  335. MySQL Optimization
  336.   Optimization Overview
  337.     MySQL Design Limitations and Tradeoffs
  338.     Designing Applications for Portability
  339.     What We Have Used MySQL For
  340.     The MySQL Benchmark Suite
  341.     Using Your Own Benchmarks
  342.   Optimizing `SELECT' Statements and Other Queries
  343.     `EXPLAIN' Syntax (Get Information About a `SELECT')
  344.     Estimating Query Performance
  345.     Speed of `SELECT' Queries
  346.     How MySQL Optimizes `WHERE' Clauses
  347.     Range Optimization
  348.       Range Access Method for Single-Part Indexes
  349.       Range Access Method for Multiple-Part Indexes
  350.     Index Merge Optimization
  351.       Index Merge Intersection Access Algorithm
  352.       Index Merge Union Access Algorithm
  353.       Index Merge Sort-Union Access Algorithm
  354.     How MySQL Optimizes `IS NULL'
  355.     How MySQL Optimizes `DISTINCT'
  356.     How MySQL Optimizes `LEFT JOIN' and `RIGHT JOIN'
  357.     How MySQL Optimizes `ORDER BY'
  358.     How MySQL Optimizes `GROUP BY'
  359.       Loose index scan
  360.       Tight index scan
  361.     How MySQL Optimizes `LIMIT'
  362.     How to Avoid Table Scans
  363.     Speed of `INSERT' Statements
  364.     Speed of `UPDATE' Statements
  365.     Speed of `DELETE' Statements
  366.     Other Optimization Tips
  367.   Locking Issues
  368.     Locking Methods
  369.     Table Locking Issues
  370.   Optimizing Database Structure
  371.     Design Choices
  372.     Make Your Data as Small as Possible
  373.     Column Indexes
  374.     Multiple-Column Indexes
  375.     How MySQL Uses Indexes
  376.     The `MyISAM' Key Cache
  377.       Shared Key Cache Access
  378.       Multiple Key Caches
  379.       Midpoint Insertion Strategy
  380.       Index Preloading
  381.       Key Cache Block Size
  382.       Restructuring a Key Cache
  383.     How MySQL Counts Open Tables
  384.     How MySQL Opens and Closes Tables
  385.     Drawbacks to Creating Many Tables in the Same Database
  386.   Optimizing the MySQL Server
  387.     System Factors and Startup Parameter Tuning
  388.     Tuning Server Parameters
  389.     Controlling Query Optimizer Performance
  390.     How Compiling and Linking Affects the Speed of MySQL
  391.     How MySQL Uses Memory
  392.     How MySQL Uses DNS
  393.   Disk Issues
  394.     Using Symbolic Links
  395.       Using Symbolic Links for Databases on Unix
  396.       Using Symbolic Links for Tables on Unix
  397.       Using Symbolic Links for Databases on Windows
  398.  
  399. MySQL Client and Utility Programs
  400.   Overview of the Client-Side Scripts and Utilities
  401.   `myisampack', the MySQL Compressed Read-only Table Generator
  402.   `mysql', the Command-Line Tool
  403.     `mysql' Commands
  404.     Executing SQL Statements from a Text File
  405.     `mysql' Tips
  406.       Displaying Query Results Vertically
  407.       Using the `--safe-updates' Option
  408.       Disabling `mysql' Auto-Reconnect
  409.   `mysqladmin', Administering a MySQL Server
  410.   The `mysqlbinlog' Binary Log Utility
  411.   `mysqlcc', the MySQL Control Center
  412.   The `mysqlcheck' Table Maintenance and Repair Program
  413.   The `mysqldump' Database Backup Program
  414.   The `mysqlhotcopy' Database Backup Program
  415.   The `mysqlimport' Data Import Program
  416.   `mysqlshow', Showing Databases, Tables, and Columns
  417.   `perror', Explaining Error Codes
  418.   The `replace' String-Replacement Utility
  419.  
  420. MySQL Language Reference
  421.  
  422. Language Structure
  423.   Literal Values
  424.     Strings
  425.     Numbers
  426.     Hexadecimal Values
  427.     Boolean Values
  428.     `NULL' Values
  429.   Database, Table, Index, Column, and Alias Names
  430.     Identifier Qualifiers
  431.     Identifier Case Sensitivity
  432.   User Variables
  433.   System Variables
  434.     Structured System Variables
  435.   Comment Syntax
  436.   Treatment of Reserved Words in MySQL
  437.  
  438. Character Set Support
  439.   Character Sets and Collations in General
  440.   Character Sets and Collations in MySQL
  441.   Determining the Default Character Set and Collation
  442.     Server Character Set and Collation
  443.     Database Character Set and Collation
  444.     Table Character Set and Collation
  445.     Column Character Set and Collation
  446.     Examples of Character Set and Collation Assignment
  447.     Connection Character Sets and Collations
  448.     Character String Literal Character Set and Collation
  449.     Using `COLLATE' in SQL Statements
  450.     `COLLATE' Clause Precedence
  451.     `BINARY' Operator
  452.     Some Special Cases Where the Collation Determination Is Tricky
  453.     Collations Must Be for the Right Character Set
  454.     An Example of the Effect of Collation
  455.   Operations Affected by Character Set Support
  456.     Result Strings
  457.     `CONVERT()'
  458.     `CAST()'
  459.     `SHOW' Statements
  460.   Unicode Support
  461.   UTF8 for Metadata
  462.   Compatibility with Other DBMSs
  463.   New Character Set Configuration File Format
  464.   National Character Set
  465.   Upgrading Character Sets from MySQL 4.0
  466.     4.0 Character Sets and Corresponding 4.1 Character Set/Collation Pairs
  467.     Converting 4.0 Character Columns to 4.1 Format
  468.   Character Sets and Collations That MySQL Supports
  469.     Unicode Character Sets
  470.     West European Character Sets
  471.     Central European Character Sets
  472.     South European and Middle East Character Sets
  473.     Baltic Character Sets
  474.     Cyrillic Character Sets
  475.     Asian Character Sets
  476.  
  477. Column Types
  478.   Column Type Overview
  479.     Overview of Numeric Types
  480.     Overview of Date and Time Types
  481.     Overview of String Types
  482.   Numeric Types
  483.   Date and Time Types
  484.     The `DATETIME', `DATE', and `TIMESTAMP' Types
  485.       `TIMESTAMP' Properties Prior to MySQL 4.1
  486.       `TIMESTAMP' Properties as of MySQL 4.1
  487.     The `TIME' Type
  488.     The `YEAR' Type
  489.     Y2K Issues and Date Types
  490.   String Types
  491.     The `CHAR' and `VARCHAR' Types
  492.     The `BLOB' and `TEXT' Types
  493.     The `ENUM' Type
  494.     The `SET' Type
  495.   Column Type Storage Requirements
  496.   Choosing the Right Type for a Column
  497.   Using Column Types from Other Database Engines
  498.  
  499. Functions and Operators
  500.   Operators
  501.     Operator Precedence
  502.     Parentheses
  503.     Comparison Functions and Operators
  504.     Logical Operators
  505.   Control Flow Functions
  506.   String Functions
  507.     String Comparison Functions
  508.   Numeric Functions
  509.     Arithmetic Operators
  510.     Mathematical Functions
  511.   Date and Time Functions
  512.   Full-Text Search Functions
  513.     Boolean Full-Text Searches
  514.     Full-Text Searches with Query Expansion
  515.     Full-Text Restrictions
  516.     Fine-Tuning MySQL Full-Text Search
  517.     Full-Text Search TODO
  518.   Cast Functions and Operators
  519.   Other Functions
  520.     Bit Functions
  521.     Encryption Functions
  522.     Information Functions
  523.     Miscellaneous Functions
  524.   Functions and Modifiers for Use with `GROUP BY' Clauses
  525.     `GROUP BY' (Aggregate) Functions
  526.     `GROUP BY' Modifiers
  527.     `GROUP BY' with Hidden Fields
  528.  
  529. SQL Statement Syntax
  530.   Data Manipulation Statements
  531.     `DELETE' Syntax
  532.     `DO' Syntax
  533.     `HANDLER' Syntax
  534.     `INSERT' Syntax
  535.       `INSERT ... SELECT' Syntax
  536.       `INSERT DELAYED' Syntax
  537.     `LOAD DATA INFILE' Syntax
  538.     `REPLACE' Syntax
  539.     `SELECT' Syntax
  540.       `JOIN' Syntax
  541.       `UNION' Syntax
  542.     Subquery Syntax
  543.       The Subquery as Scalar Operand
  544.       Comparisons Using Subqueries
  545.       Subqueries with `ANY', `IN', and `SOME'
  546.       Subqueries with `ALL'
  547.       Correlated Subqueries
  548.       `EXISTS' and `NOT EXISTS'
  549.       Row Subqueries
  550.       Subqueries in the `FROM' clause
  551.       Subquery Errors
  552.       Optimizing Subqueries
  553.       Rewriting Subqueries as Joins for Earlier MySQL Versions
  554.     `TRUNCATE' Syntax
  555.     `UPDATE' Syntax
  556.   Data Definition Statements
  557.     `ALTER DATABASE' Syntax
  558.     `ALTER TABLE' Syntax
  559.     `ALTER VIEW' Syntax
  560.     `CREATE DATABASE' Syntax
  561.     `CREATE INDEX' Syntax
  562.     `CREATE TABLE' Syntax
  563.       Silent Column Specification Changes
  564.     `CREATE VIEW' Syntax
  565.     `DROP DATABASE' Syntax
  566.     `DROP INDEX' Syntax
  567.     `DROP TABLE' Syntax
  568.     `DROP VIEW' Syntax
  569.     `RENAME TABLE' Syntax
  570.   MySQL Utility Statements
  571.     `DESCRIBE' Syntax (Get Information About Columns)
  572.     `USE' Syntax
  573.   MySQL Transactional and Locking Statements
  574.     `START TRANSACTION', `COMMIT', and `ROLLBACK' Syntax
  575.     Statements That Cannot Be Rolled Back
  576.     Statements That Cause an Implicit Commit
  577.     `SAVEPOINT' and `ROLLBACK TO SAVEPOINT' Syntax
  578.     `LOCK TABLES' and `UNLOCK TABLES' Syntax
  579.     `SET TRANSACTION' Syntax
  580.   Database Administration Statements
  581.     Account Management Statements
  582.       `DROP USER' Syntax
  583.       `GRANT' and `REVOKE' Syntax
  584.       `SET PASSWORD' Syntax
  585.     Table Maintenance Statements
  586.       `ANALYZE TABLE' Syntax
  587.       `BACKUP TABLE' Syntax
  588.       `CHECK TABLE' Syntax
  589.       `CHECKSUM TABLE' Syntax
  590.       `OPTIMIZE TABLE' Syntax
  591.       `REPAIR TABLE' Syntax
  592.       `RESTORE TABLE' Syntax
  593.     `SET' and `SHOW' Syntax
  594.       `SET' Syntax
  595.       `SHOW CHARACTER SET' Syntax
  596.       `SHOW COLLATION' Syntax
  597.       `SHOW COLUMNS' Syntax
  598.       `SHOW CREATE DATABASE' Syntax
  599.       `SHOW CREATE TABLE' Syntax
  600.       `SHOW CREATE VIEW' Syntax
  601.       `SHOW DATABASES' Syntax
  602.       `SHOW ENGINES' Syntax
  603.       `SHOW ERRORS' Syntax
  604.       `SHOW GRANTS' Syntax
  605.       `SHOW INDEX' Syntax
  606.       `SHOW INNODB STATUS' Syntax
  607.       `SHOW LOGS' Syntax
  608.       `SHOW PRIVILEGES' Syntax
  609.       `SHOW PROCESSLIST' Syntax
  610.       `SHOW STATUS' Syntax
  611.       `SHOW TABLE STATUS' Syntax
  612.       `SHOW TABLES' Syntax
  613.       `SHOW VARIABLES' Syntax
  614.       `SHOW WARNINGS' Syntax
  615.     Other Administrative Statements
  616.       `CACHE INDEX' Syntax
  617.       `FLUSH' Syntax
  618.       `KILL' Syntax
  619.       `LOAD INDEX INTO CACHE' Syntax
  620.       `RESET' Syntax
  621.   Replication Statements
  622.     SQL Statements for Controlling Master Servers
  623.       `PURGE MASTER LOGS' Syntax
  624.       `RESET MASTER' Syntax
  625.       `SET SQL_LOG_BIN' Syntax
  626.       `SHOW BINLOG EVENTS' Syntax
  627.       `SHOW MASTER LOGS' Syntax
  628.       `SHOW MASTER STATUS' Syntax
  629.       `SHOW SLAVE HOSTS' Syntax
  630.     SQL Statements for Controlling Slave Servers
  631.       `CHANGE MASTER TO' Syntax
  632.       `LOAD DATA FROM MASTER' Syntax
  633.       `LOAD TABLE TBL_NAME FROM MASTER' Syntax
  634.       `MASTER_POS_WAIT()' Syntax
  635.       `RESET SLAVE' Syntax
  636.       `SET GLOBAL SQL_SLAVE_SKIP_COUNTER' Syntax
  637.       `SHOW SLAVE STATUS' Syntax
  638.       `START SLAVE' Syntax
  639.       `STOP SLAVE' Syntax
  640.   SQL Syntax for Prepared Statements
  641.  
  642. MySQL Storage Engines and Table Types
  643.   The `MyISAM' Storage Engine
  644.     `MyISAM' Startup Options
  645.     Space Needed for Keys
  646.     `MyISAM' Table Storage Formats
  647.       Static (Fixed-Length) Table Characteristics
  648.       Dynamic Table Characteristics
  649.       Compressed Table Characteristics
  650.     `MyISAM' Table Problems
  651.       Corrupted `MyISAM' Tables
  652.       Problems from Tables Not Being Closed Properly
  653.   The `MERGE' Storage Engine
  654.     `MERGE' Table Problems
  655.   The `MEMORY' (`HEAP') Storage Engine
  656.   The `BDB' (`BerkeleyDB') Storage Engine
  657.     Operating Systems Supported by `BDB'
  658.     Installing `BDB'
  659.     `BDB' Startup Options
  660.     Characteristics of `BDB' Tables
  661.     Things We Need to Fix for `BDB'
  662.     Restrictions on `BDB' Tables
  663.     Errors That May Occur When Using `BDB' Tables
  664.   The `ISAM' Storage Engine
  665.  
  666. The `InnoDB' Storage Engine
  667.   `InnoDB' Overview
  668.   `InnoDB' Contact Information
  669.   `InnoDB' in MySQL 3.23
  670.   `InnoDB' Configuration
  671.   `InnoDB' Startup Options
  672.   Creating the `InnoDB' Tablespace
  673.     Dealing with `InnoDB' Initialization Problems
  674.   Creating `InnoDB' Tables
  675.     How to Use Transactions in `InnoDB' with Different APIs
  676.     Converting `MyISAM' Tables to `InnoDB'
  677.     How an `AUTO_INCREMENT' Column Works in `InnoDB'
  678.     `FOREIGN KEY' Constraints
  679.     `InnoDB' and MySQL Replication
  680.     Using Per-Table Tablespaces
  681.   Adding and Removing `InnoDB' Data and Log Files
  682.   Backing Up and Recovering an `InnoDB' Database
  683.     Forcing Recovery
  684.     Checkpoints
  685.   Moving an `InnoDB' Database to Another Machine
  686.   `InnoDB' Transaction Model and Locking
  687.     `InnoDB' and `AUTOCOMMIT'
  688.     `InnoDB' and `TRANSACTION ISOLATION LEVEL'
  689.     Consistent Non-Locking Read
  690.     Locking Reads `SELECT ... FOR UPDATE' and `SELECT ... LOCK IN SHARE MODE'
  691.     Next-Key Locking: Avoiding the Phantom Problem
  692.     An Example of How the Consistent Read Works in `InnoDB'
  693.     Locks Set by Different SQL Statements in `InnoDB'
  694.     When Does MySQL Implicitly Commit or Roll Back a Transaction?
  695.     Deadlock Detection and Rollback
  696.     How to Cope with Deadlocks
  697.   `InnoDB' Performance Tuning Tips
  698.     `SHOW INNODB STATUS' and the `InnoDB' Monitors
  699.   Implementation of Multi-Versioning
  700.   Table and Index Structures
  701.     Physical Structure of an Index
  702.     Insert Buffering
  703.     Adaptive Hash Indexes
  704.     Physical Record Structure
  705.   File Space Management and Disk I/O
  706.     Disk I/O
  707.     Using Raw Devices for the Tablespace
  708.     File Space Management
  709.     Defragmenting a Table
  710.   Error Handling
  711.     `InnoDB' Error Codes
  712.     Operating System Error Codes
  713.   Restrictions on `InnoDB' Tables
  714.   `InnoDB' Troubleshooting
  715.     Troubleshooting `InnoDB' Data Dictionary Operations
  716.  
  717. MySQL Cluster
  718.   MySQL Cluster Overview
  719.   Basic MySQL Cluster Concepts
  720.   MySQL Cluster Configuration
  721.     Building from Source Code
  722.     Installing the Software
  723.     Quick Test Setup of MySQL Cluster
  724.     Configuration File
  725.       An Example Configuration in a MySQL Cluster
  726.       Defining the Computers in a MySQL Cluster
  727.       Defining the Management Server in a MySQL Cluster
  728.       Defining the Storage Nodes in a MySQL Cluster
  729.       Defining the MySQL Servers in a MySQL Cluster
  730.       Defining TCP/IP Connections in a MySQL Cluster
  731.       Defining Shared-Memory Connections in a MySQL Cluster
  732.       Defining SCI Transporter Connections in a MySQL Cluster
  733.   Process Management in MySQL Cluster
  734.     MySQL Server Process Usage for MySQL Cluster
  735.     `ndbd', the Storage Engine Node Process
  736.     `ndb_mgmd', the Management Server Process
  737.     `ndb_mgm', the Management Client Process
  738.     Command Options for MySQL Cluster Processes
  739.       MySQL Cluster-Related Command Options for `mysqld'
  740.       Command Options for `ndbd'
  741.       Command Options for `ndb_mgmd'
  742.       Command Options for `ndb_mgm'
  743.   Management of MySQL Cluster
  744.     Commands in the Management Client
  745.     Event Reports Generated in MySQL Cluster
  746.       Logging Management Commands
  747.       Log Events
  748.     Single User Mode
  749.     On-line Backup of MySQL Cluster
  750.       Cluster Backup Concepts
  751.       Using The Management Server to Create a Backup
  752.       How to Restore a Cluster Backup
  753.       Configuration for Cluster Backup
  754.       Backup Troubleshooting
  755.   Using High-Speed Interconnects with MySQL Cluster
  756.     Configuring MySQL Cluster to use SCI Sockets
  757.     Low-level benchmarks to understand impact of cluster interconnects
  758.  
  759. Introduction to MaxDB
  760.   History of MaxDB
  761.   Licensing and Support
  762.   MaxDB-Related Links
  763.   Basic Concepts of MaxDB
  764.   Feature Differences Between MaxDB and MySQL
  765.   Interoperability Features Between MaxDB and MySQL
  766.   Reserved Words in MaxDB
  767.  
  768. Spatial Extensions in MySQL
  769.   Introduction
  770.   The OpenGIS Geometry Model
  771.     The Geometry Class Hierarchy
  772.     Class `Geometry'
  773.     Class `Point'
  774.     Class `Curve'
  775.     Class `LineString'
  776.     Class `Surface'
  777.     Class `Polygon'
  778.     Class `GeometryCollection'
  779.     Class `MultiPoint'
  780.     Class `MultiCurve'
  781.     Class `MultiLineString'
  782.     Class `MultiSurface'
  783.     Class `MultiPolygon'
  784.   Supported Spatial Data Formats
  785.     Well-Known Text (WKT) Format
  786.     Well-Known Binary (WKB) Format
  787.   Creating a Spatially Enabled MySQL Database
  788.     MySQL Spatial Data Types
  789.     Creating Spatial Values
  790.       Creating Geometry Values Using WKT Functions
  791.       Creating Geometry Values Using WKB Functions
  792.       Creating Geometry Values Using MySQL-Specific Functions
  793.     Creating Spatial Columns
  794.     Populating Spatial Columns
  795.     Fetching Spatial Data
  796.       Fetching Spatial Data in Internal Format
  797.       Fetching Spatial Data in WKT Format
  798.       Fetching Spatial Data in WKB Format
  799.   Analyzing Spatial Information
  800.     Geometry Format Conversion Functions
  801.     `Geometry' Functions
  802.       General Geometry Functions
  803.       `Point' Functions
  804.       `LineString' Functions
  805.       `MultiLineString' Functions
  806.       `Polygon' Functions
  807.       `MultiPolygon' Functions
  808.       `GeometryCollection' Functions
  809.     Functions That Create New Geometries from Existing Ones
  810.       Geometry Functions That Produce New Geometries
  811.       Spatial Operators
  812.     Functions for Testing Spatial Relations Between Geometric Objects
  813.     Relations on Geometry Minimal Bounding Rectangles (MBRs)
  814.     Functions That Test Spatial Relationships Between Geometries
  815.   Optimizing Spatial Analysis
  816.     Creating Spatial Indexes
  817.     Using a Spatial Index
  818.   MySQL Conformance and Compatibility
  819.     GIS Features That Are Not Yet Implemented
  820.  
  821. Stored Procedures and Functions
  822.   Stored Procedure Syntax
  823.     Maintaining Stored Procedures
  824.       `CREATE PROCEDURE' and `CREATE FUNCTION'
  825.       `ALTER PROCEDURE' and `ALTER FUNCTION'
  826.       `DROP PROCEDURE' and `DROP FUNCTION'
  827.       `SHOW CREATE PROCEDURE' and `SHOW CREATE FUNCTION'
  828.     `SHOW PROCEDURE STATUS' and `SHOW FUNCTION STATUS'
  829.     `CALL' Statement
  830.     `BEGIN ... END' Compound Statement
  831.     `DECLARE' Statement
  832.     Variables in Stored Procedures
  833.       `DECLARE' Local Variables
  834.       Variable `SET' Statement
  835.       `SELECT ... INTO' Statement
  836.     Conditions and Handlers
  837.       `DECLARE' Conditions
  838.       `DECLARE' Handlers
  839.     Cursors
  840.       Declaring Cursors
  841.       Cursor `OPEN' Statement
  842.       Cursor `FETCH' Statement
  843.       Cursor `CLOSE' Statement
  844.     Flow Control Constructs
  845.       `IF' Statement
  846.       `CASE' Statement
  847.       `LOOP' Statement
  848.       `LEAVE' Statement
  849.       `ITERATE' Statement
  850.       `REPEAT' Statement
  851.       `WHILE' Statement
  852.  
  853. MySQL APIs
  854.   MySQL Program Development Utilities
  855.     `msql2mysql', Convert mSQL Programs for Use with MySQL
  856.     `mysql_config', Get compile options for compiling clients
  857.   MySQL C API
  858.     C API Data types
  859.     C API Function Overview
  860.     C API Function Descriptions
  861.       `mysql_affected_rows()'
  862.       `mysql_change_user()'
  863.       `mysql_character_set_name()'
  864.       `mysql_close()'
  865.       `mysql_connect()'
  866.       `mysql_create_db()'
  867.       `mysql_data_seek()'
  868.       `mysql_debug()'
  869.       `mysql_drop_db()'
  870.       `mysql_dump_debug_info()'
  871.       `mysql_eof()'
  872.       `mysql_errno()'
  873.       `mysql_error()'
  874.       `mysql_escape_string()'
  875.       `mysql_fetch_field()'
  876.       `mysql_fetch_fields()'
  877.       `mysql_fetch_field_direct()'
  878.       `mysql_fetch_lengths()'
  879.       `mysql_fetch_row()'
  880.       `mysql_field_count()'
  881.       `mysql_field_seek()'
  882.       `mysql_field_tell()'
  883.       `mysql_free_result()'
  884.       `mysql_get_client_info()'
  885.       `mysql_get_client_version()'
  886.       `mysql_get_host_info()'
  887.       `mysql_get_proto_info()'
  888.       `mysql_get_server_info()'
  889.       `mysql_get_server_version()'
  890.       `mysql_info()'
  891.       `mysql_init()'
  892.       `mysql_insert_id()'
  893.       `mysql_kill()'
  894.       `mysql_list_dbs()'
  895.       `mysql_list_fields()'
  896.       `mysql_list_processes()'
  897.       `mysql_list_tables()'
  898.       `mysql_num_fields()'
  899.       `mysql_num_rows()'
  900.       `mysql_options()'
  901.       `mysql_ping()'
  902.       `mysql_query()'
  903.       `mysql_real_connect()'
  904.       `mysql_real_escape_string()'
  905.       `mysql_real_query()'
  906.       `mysql_reload()'
  907.       `mysql_row_seek()'
  908.       `mysql_row_tell()'
  909.       `mysql_select_db()'
  910.       `mysql_set_server_option()'
  911.       `mysql_shutdown()'
  912.       `mysql_sqlstate()'
  913.       `mysql_ssl_set()'
  914.       `mysql_stat()'
  915.       `mysql_store_result()'
  916.       `mysql_thread_id()'
  917.       `mysql_use_result()'
  918.       `mysql_warning_count()'
  919.       `mysql_commit()'
  920.       `mysql_rollback()'
  921.       `mysql_autocommit()'
  922.       `mysql_more_results()'
  923.       `mysql_next_result()'
  924.     C API Prepared Statements
  925.     C API Prepared Statement Data types
  926.     C API Prepared Statement Function Overview
  927.     C API Prepared Statement Function Descriptions
  928.       `mysql_stmt_affected_rows()'
  929.       `mysql_stmt_attr_get()'
  930.       `mysql_stmt_attr_set()'
  931.       `mysql_stmt_bind_param()'
  932.       `mysql_stmt_bind_result()'
  933.       `mysql_stmt_close()'
  934.       `mysql_stmt_data_seek()'
  935.       `mysql_stmt_errno()'
  936.       `mysql_stmt_error()'
  937.       `mysql_stmt_execute()'
  938.       `mysql_stmt_free_result()'
  939.       `mysql_stmt_insert_id()'
  940.       `mysql_stmt_fetch()'
  941.       `mysql_stmt_fetch_column()'
  942.       `mysql_stmt_field_count()'
  943.       `mysql_stmt_init()'
  944.       `mysql_stmt_num_rows()'
  945.       `mysql_stmt_param_count()'
  946.       `mysql_stmt_param_metadata()'
  947.       `mysql_stmt_prepare()'
  948.       `mysql_stmt_reset()'
  949.       `mysql_stmt_result_metadata()'
  950.       `mysql_stmt_row_seek()'
  951.       `mysql_stmt_row_tell()'
  952.       `mysql_stmt_send_long_data()'
  953.       `mysql_stmt_sqlstate()'
  954.       `mysql_stmt_store_result()'
  955.     C API Prepared statement problems
  956.     C API Handling of Multiple Query Execution
  957.     C API Handling of Date and Time Values
  958.     C API Threaded Function Descriptions
  959.       `my_init()'
  960.       `mysql_thread_init()'
  961.       `mysql_thread_end()'
  962.       `mysql_thread_safe()'
  963.     C API Embedded Server Function Descriptions
  964.       `mysql_server_init()'
  965.       `mysql_server_end()'
  966.     Common questions and problems when using the C API
  967.       Why `mysql_store_result()' Sometimes Returns `NULL' After `mysql_query()' Returns Success
  968.       What Results You Can Get from a Query
  969.       How to Get the Unique ID for the Last Inserted Row
  970.       Problems Linking with the C API
  971.     Building Client Programs
  972.     How to Make a Threaded Client
  973.     libmysqld, the Embedded MySQL Server Library
  974.       Overview of the Embedded MySQL Server Library
  975.       Compiling Programs with `libmysqld'
  976.       Restrictions when using the Embedded MySQL Server
  977.       Using Option Files with the Embedded Server
  978.       Things left to do in Embedded Server (TODO)
  979.       A Simple Embedded Server Example
  980.       Licensing the Embedded Server
  981.   MySQL PHP API
  982.     Common Problems with MySQL and PHP
  983.   MySQL Perl API
  984.   MySQL C++ API
  985.     Borland C++
  986.   MySQL Python API
  987.   MySQL Tcl API
  988.   MySQL Eiffel Wrapper
  989.  
  990. MySQL Connectors
  991.   MySQL ODBC Support
  992.     Introduction to MyODBC
  993.       What is ODBC?
  994.       What is Connector/ODBC?
  995.       What is MyODBC 2.50?
  996.       What is MyODBC 3.51?
  997.       Where to Get MyODBC
  998.       Supported Platforms
  999.       MyODBC Mailing List
  1000.       How to Get MyODBC Support
  1001.       How to Report MyODBC Problems or Bugs
  1002.       How to Request a MyODBC Feature or Patch
  1003.       How to Submit a MyODBC Patch
  1004.     General Information About ODBC and MyODBC
  1005.       Introduction to ODBC
  1006.       MyODBC Architecture
  1007.       ODBC Driver Managers
  1008.       Types of MySQL ODBC Drivers
  1009.     How to Install MyODBC
  1010.     Installing MyODBC from a Binary Distribution on Windows
  1011.     Installing MyODBC from a Binary Distribution on Unix
  1012.       Installing MyODBC from an RPM Distribution
  1013.       Installing MyODBC from a Binary Tarball Distribution
  1014.     Installing MyODBC from a Source Distribution on Windows
  1015.       Requirements
  1016.       Building MyODBC 3.51
  1017.       Testing
  1018.       Building MyODBC 2.50
  1019.     Installing MyODBC from a Source Distribution on Unix
  1020.       Requirements
  1021.       Typical `configure' Options
  1022.       Thread-Safe Client
  1023.       Shared or Static Options
  1024.       Enabling Debugging Information
  1025.       Enabling the Documentation
  1026.       Building and Compilation
  1027.       Building Shared Libraries
  1028.       Installing Driver Libraries
  1029.       Testing MyODBC on Unix
  1030.       Mac OS X Notes
  1031.       HP-UX Notes
  1032.       AIX Notes:
  1033.     Installing MyODBC from the BitKeeper Development Source Tree
  1034.     MyODBC Configuration
  1035.       What is a Data Source Name?
  1036.       Configuring a MyODBC DSN on Windows
  1037.       Configuring a MyODBC DSN on Unix
  1038.       Connection Parameters
  1039.       Connecting Without a Predefined DSN
  1040.       Establishing a Remote Connection to System A from System B
  1041.       Getting an ODBC Trace File
  1042.       Applications Tested with MyODBC
  1043.       Programs Known to Work With MyODBC
  1044.     MyODBC Connection-Related Issues
  1045.       While Configuring a MyODBC DSN, a `Could Not Load Translator or Setup Library' Error Occurs
  1046.       While Connecting, an `Access denied' Error Occurs
  1047.       INFO: About ODBC Connection Pooling
  1048.     MyODBC and Microsoft Access
  1049.       How to Set Up Microsoft Access to Work with MySQL using MyODBC?
  1050.       How to Export a Table or Query from Access to MySQL?
  1051.       How to Import or Link MySQL Database Tables to Access?
  1052.       The Structure or Location of a Linked Table has been Changed. Can I See Those Changes Locally in Linked Tables?
  1053.       When I Insert or Update a Record in Linked Tables, I Get `#DELETED#'
  1054.       How Do I Handle Write Conflicts or Row Location Errors?
  1055.       Whenever I Export a Table from Access 97, a Strange Syntax Error Occurs
  1056.       Access Returns `Another user has modified the record that you have modified' While Editing Records
  1057.       How to Trap ODBC Login Error Messages in Access?
  1058.       How Do I Optimize Access for Performance with MyODBC?
  1059.       I Have Very Long Tables. What is the Best Configuration for MyODBC to Access These Tables?
  1060.       How to Set the QueryTimeout Value for ODBC Connections?
  1061.       INFO: Tools to Export/Import from/to Access to/from MySQL
  1062.     MyODBC and Microsoft VBA and ASP
  1063.       Why Does `SELECT COUNT(*) FROM TBL_NAME' Return an Error?
  1064.       Whenever I Use the `AppendChunk()' or `GetChunk()' ADO Methods, I Get an Error `Multiple-step operation generated errors. Check each status value'.
  1065.       How to Find the Total Number of Rows Affected by a Particular SQL Statement in ADO?
  1066.       How Do I Handle Blob Data in Visual Basic?
  1067.       How Do I Map Visual Basic Data Types to MySQL Types?
  1068.       SAMPLES: VB with ADO, DAO and RDO
  1069.       ASP and MySQL with MyODBC
  1070.       INFO: Frequently Asked Questions on ActiveX Data Objects (ADO)
  1071.     MyODBC and Third-Party ODBC Tools
  1072.       How to Retrieve Data from MySQL into MS-Word/Excel Documents?
  1073.       Exporting Tables from MS DTS to MySQL Using MyODBC Results in a Syntax Error
  1074.       HOWTO: Configure MySQL+MyODBC+unixODBC+ColdFusion on Solaris
  1075.     MyODBC General Functionality
  1076.       How to Get the Value of an `AUTO_INCREMENT' Column in ODBC
  1077.       Does MyODBC Support Dynamic Cursor Type?
  1078.       What Causes `Transactions are not enabled' Errors?
  1079.       What Causes `Cursor not found' Errors?
  1080.       Can I Use MyODBC 2.50 Applications with MyODBC 3.51?
  1081.       Can I Access MySQL from .NET Environment Using MyODBC?
  1082.       Why Does MyODBC Perform Poorly, and Also Make a Lot of Disk Activity for Relatively Small Queries?
  1083.     Basic MyODBC Application Steps
  1084.     MyODBC API Reference
  1085.     MyODBC Data Types
  1086.     MyODBC Error Codes
  1087.     MyODBC With VB: ADO, DAO and RDO
  1088.       ADO: `rs.addNew', `rs.delete', and `rs.update'
  1089.       DAO: `rs.addNew', `rs.update', and Scrolling
  1090.       RDO: `rs.addNew' and `rs.update'
  1091.     MyODBC with Microsoft .NET
  1092.       ODBC.NET: CSHARP(C#)
  1093.       ODBC.NET: VB
  1094.     Credits
  1095.   MySQL Java Connectivity (JDBC)
  1096.  
  1097. Error Handling in MySQL
  1098.  
  1099. Extending MySQL
  1100.   MySQL Internals
  1101.     MySQL Threads
  1102.     MySQL Test Suite
  1103.       Running the MySQL Test Suite
  1104.       Extending the MySQL Test Suite
  1105.       Reporting Bugs in the MySQL Test Suite
  1106.   Adding New Functions to MySQL
  1107.     `CREATE FUNCTION/DROP FUNCTION' Syntax
  1108.     Adding a New User-defined Function
  1109.       UDF Calling Sequences for simple functions
  1110.       UDF Calling Sequences for aggregate functions
  1111.       Argument Processing
  1112.       Return Values and Error Handling
  1113.       Compiling and Installing User-defined Functions
  1114.     Adding a New Native Function
  1115.   Adding New Procedures to MySQL
  1116.     Procedure Analyse
  1117.     Writing a Procedure
  1118.  
  1119. Problems and Common Errors
  1120.   How to Determine What Is Causing a Problem
  1121.   Common Errors When Using MySQL Programs
  1122.     `Access denied'
  1123.     `Can't connect to [local] MySQL server'
  1124.     `Client does not support authentication protocol'
  1125.     Password Fails When Entered Interactively
  1126.     `Host 'HOST_NAME' is blocked'
  1127.     `Too many connections'
  1128.     `Out of memory'
  1129.     `MySQL server has gone away'
  1130.     `Packet too large'
  1131.     Communication Errors and Aborted Connections
  1132.     `The table is full'
  1133.     `Can't create/write to file'
  1134.     `Commands out of sync'
  1135.     `Ignoring user'
  1136.     `Table 'TBL_NAME' doesn't exist'
  1137.     `Can't initialize character set'
  1138.     File Not Found
  1139.   Installation-Related Issues
  1140.     Problems Linking to the MySQL Client Library
  1141.     How to Run MySQL as a Normal User
  1142.     Problems with File Permissions
  1143.   Administration-Related Issues
  1144.     How to Reset the Root Password
  1145.     What to Do If MySQL Keeps Crashing
  1146.     How MySQL Handles a Full Disk
  1147.     Where MySQL Stores Temporary Files
  1148.     How to Protect or Change the MySQL Socket File `/tmp/mysql.sock'
  1149.     Time Zone Problems
  1150.   Query-Related Issues
  1151.     Case Sensitivity in Searches
  1152.     Problems Using `DATE' Columns
  1153.     Problems with `NULL' Values
  1154.     Problems with Column Aliases
  1155.     Rollback Failure for Non-Transactional Tables
  1156.     Deleting Rows from Related Tables
  1157.     Solving Problems with No Matching Rows
  1158.     Problems with Floating-Point Comparisons
  1159.   Optimizer-Related Issues
  1160.   Table Definition-Related Issues
  1161.     Problems with `ALTER TABLE'
  1162.     How to Change the Order of Columns in a Table
  1163.     `TEMPORARY TABLE' Problems
  1164.  
  1165. Credits
  1166.   Developers at MySQL AB
  1167.   Contributors to MySQL
  1168.   Documenters and translators
  1169.   Libraries used by and included with MySQL
  1170.   Packages that support MySQL
  1171.   Tools that were used to create MySQL
  1172.   Supporters of MySQL
  1173.  
  1174. MySQL Change History
  1175.   Changes in release 5.0.x (Development)
  1176.     Changes in release 5.0.2 (not released yet)
  1177.     Changes in release 5.0.1 (27 Jul 2004)
  1178.     Changes in release 5.0.0 (22 Dec 2003: Alpha)
  1179.   Changes in release 4.1.x (Gamma)
  1180.     Changes in release 4.1.8 (not released yet)
  1181.     Changes in release 4.1.7 (23 Oct 2004: Production)
  1182.     Changes in release 4.1.6 (10 Oct 2004)
  1183.     Changes in release 4.1.5 (16 Sep 2004)
  1184.     Changes in release 4.1.4 (26 Aug 2004: Gamma)
  1185.     Changes in release 4.1.3 (28 Jun 2004: Beta)
  1186.     Changes in release 4.1.2 (28 May 2004)
  1187.     Changes in release 4.1.1 (01 Dec 2003)
  1188.     Changes in release 4.1.0 (03 Apr 2003: Alpha)
  1189.   Changes in release 4.0.x (Production)
  1190.     Changes in release 4.0.23 (not released yet)
  1191.     Changes in release 4.0.22 (to be released soon)
  1192.     Changes in release 4.0.21 (06 Sep 2004)
  1193.     Changes in release 4.0.20 (17 May 2004)
  1194.     Changes in release 4.0.19 (04 May 2004)
  1195.     Changes in release 4.0.18 (12 Feb 2004)
  1196.     Changes in release 4.0.17 (14 Dec 2003)
  1197.     Changes in release 4.0.16 (17 Oct 2003)
  1198.     Changes in release 4.0.15 (03 Sep 2003)
  1199.     Changes in release 4.0.14 (18 Jul 2003)
  1200.     Changes in release 4.0.13 (16 May 2003)
  1201.     Changes in release 4.0.12 (15 Mar 2003: Production)
  1202.     Changes in release 4.0.11 (20 Feb 2003)
  1203.     Changes in release 4.0.10 (29 Jan 2003)
  1204.     Changes in release 4.0.9 (09 Jan 2003)
  1205.     Changes in release 4.0.8 (07 Jan 2003)
  1206.     Changes in release 4.0.7 (20 Dec 2002)
  1207.     Changes in release 4.0.6 (14 Dec 2002: Gamma)
  1208.     Changes in release 4.0.5 (13 Nov 2002)
  1209.     Changes in release 4.0.4 (29 Sep 2002)
  1210.     Changes in release 4.0.3 (26 Aug 2002: Beta)
  1211.     Changes in release 4.0.2 (01 Jul 2002)
  1212.     Changes in release 4.0.1 (23 Dec 2001)
  1213.     Changes in release 4.0.0 (Oct 2001: Alpha)
  1214.   Changes in release 3.23.x (Recent; still supported)
  1215.     Changes in release 3.23.59 (not released yet)
  1216.     Changes in release 3.23.58 (11 Sep 2003)
  1217.     Changes in release 3.23.57 (06 Jun 2003)
  1218.     Changes in release 3.23.56 (13 Mar 2003)
  1219.     Changes in release 3.23.55 (23 Jan 2003)
  1220.     Changes in release 3.23.54 (05 Dec 2002)
  1221.     Changes in release 3.23.53 (09 Oct 2002)
  1222.     Changes in release 3.23.52 (14 Aug 2002)
  1223.     Changes in release 3.23.51 (31 May 2002)
  1224.     Changes in release 3.23.50 (21 Apr 2002)
  1225.     Changes in release 3.23.49 (14 Feb 2002)
  1226.     Changes in release 3.23.48 (07 Feb 2002)
  1227.     Changes in release 3.23.47 (27 Dec 2001)
  1228.     Changes in release 3.23.46 (29 Nov 2001)
  1229.     Changes in release 3.23.45 (22 Nov 2001)
  1230.     Changes in release 3.23.44 (31 Oct 2001)
  1231.     Changes in release 3.23.43 (04 Oct 2001)
  1232.     Changes in release 3.23.42 (08 Sep 2001)
  1233.     Changes in release 3.23.41 (11 Aug 2001)
  1234.     Changes in release 3.23.40 (18 Jul 2001)
  1235.     Changes in release 3.23.39 (12 Jun 2001)
  1236.     Changes in release 3.23.38 (09 May 2001)
  1237.     Changes in release 3.23.37 (17 Apr 2001)
  1238.     Changes in release 3.23.36 (27 Mar 2001)
  1239.     Changes in release 3.23.35 (15 Mar 2001)
  1240.     Changes in release 3.23.34a (11 Mar 2001)
  1241.     Changes in release 3.23.34 (10 Mar 2001)
  1242.     Changes in release 3.23.33 (09 Feb 2001)
  1243.     Changes in release 3.23.32 (22 Jan 2001)
  1244.     Changes in release 3.23.31 (17 Jan 2001: Production)
  1245.     Changes in release 3.23.30 (04 Jan 2001)
  1246.     Changes in release 3.23.29 (16 Dec 2000)
  1247.     Changes in release 3.23.28 (22 Nov 2000: Gamma)
  1248.     Changes in release 3.23.27 (24 Oct 2000)
  1249.     Changes in release 3.23.26 (18 Oct 2000)
  1250.     Changes in release 3.23.25 (29 Sep 2000)
  1251.     Changes in release 3.23.24 (08 Sep 2000)
  1252.     Changes in release 3.23.23 (01 Sep 2000)
  1253.     Changes in release 3.23.22 (31 Jul 2000)
  1254.     Changes in release 3.23.21 (04 Jul 2000)
  1255.     Changes in release 3.23.20 (28 Jun 2000: Beta)
  1256.     Changes in release 3.23.19
  1257.     Changes in release 3.23.18 (11 Jun 2000)
  1258.     Changes in release 3.23.17 (07 Jun 2000)
  1259.     Changes in release 3.23.16 (16 May 2000)
  1260.     Changes in release 3.23.15 (08 May 2000)
  1261.     Changes in release 3.23.14 (09 Apr 2000)
  1262.     Changes in release 3.23.13 (14 Mar 2000)
  1263.     Changes in release 3.23.12 (07 Mar 2000)
  1264.     Changes in release 3.23.11 (16 Feb 2000)
  1265.     Changes in release 3.23.10 (30 Jan 2000)
  1266.     Changes in release 3.23.9 (29 Jan 2000)
  1267.     Changes in release 3.23.8 (02 Jan 2000)
  1268.     Changes in release 3.23.7 (10 Dec 1999)
  1269.     Changes in release 3.23.6 (15 Nov 1999)
  1270.     Changes in release 3.23.5 (20 Oct 1999)
  1271.     Changes in release 3.23.4 (28 Sep 1999)
  1272.     Changes in release 3.23.3 (13 Sep 1999)
  1273.     Changes in release 3.23.2 (09 Aug 1999)
  1274.     Changes in release 3.23.1 (08 Jul 1999)
  1275.     Changes in release 3.23.0 (05 Jul 1999: Alpha)
  1276.   Changes in release 3.22.x (Old; discontinued)
  1277.     Changes in release 3.22.35
  1278.     Changes in release 3.22.34
  1279.     Changes in release 3.22.33
  1280.     Changes in release 3.22.32 (14 Feb 2000)
  1281.     Changes in release 3.22.31
  1282.     Changes in release 3.22.30 (11 Jan 2000)
  1283.     Changes in release 3.22.29 (02 Jan 2000)
  1284.     Changes in release 3.22.28 (20 Oct 1999)
  1285.     Changes in release 3.22.27 (05 Oct 1999)
  1286.     Changes in release 3.22.26 (16 Sep 1999)
  1287.     Changes in release 3.22.25 (07 Jun 1999)
  1288.     Changes in release 3.22.24 (05 Jul 1999)
  1289.     Changes in release 3.22.23 (08 Jun 1999)
  1290.     Changes in release 3.22.22 (30 Apr 1999)
  1291.     Changes in release 3.22.21 (04 Apr 1999)
  1292.     Changes in release 3.22.20 (18 Mar 1999)
  1293.     Changes in release 3.22.19 (01 Mar 1999)
  1294.     Changes in release 3.22.18 (26 Feb 1999)
  1295.     Changes in release 3.22.17 (22 Feb 1999: Production)
  1296.     Changes in release 3.22.16 (05 Feb 1999)
  1297.     Changes in release 3.22.15 (27 Jan 1999)
  1298.     Changes in release 3.22.14 (01 Jan 1999: Gamma)
  1299.     Changes in release 3.22.13 (16 Dec 1998)
  1300.     Changes in release 3.22.12 (09 Dec 1998)
  1301.     Changes in release 3.22.11 (24 Nov 1998)
  1302.     Changes in release 3.22.10 (04 Nov 1998)
  1303.     Changes in release 3.22.9 (19 Oct 1998)
  1304.     Changes in release 3.22.8 (06 Oct 1998)
  1305.     Changes in release 3.22.7 (21 Sep 1998: Beta)
  1306.     Changes in release 3.22.6 (31 Aug 1998)
  1307.     Changes in release 3.22.5 (20 Aug 1998: Alpha)
  1308.     Changes in release 3.22.4 (06 Jul 1998: Beta)
  1309.     Changes in release 3.22.3 (30 Jun 1998)
  1310.     Changes in release 3.22.2
  1311.     Changes in release 3.22.1 (Jun 1998)
  1312.     Changes in release 3.22.0 (18 May 1998: Alpha)
  1313.   Changes in release 3.21.x
  1314.     Changes in release 3.21.33 (08 Jul 1998)
  1315.     Changes in release 3.21.32 (30 Jun 1998)
  1316.     Changes in release 3.21.31 (10 Jun 1998)
  1317.     Changes in release 3.21.30
  1318.     Changes in release 3.21.29
  1319.     Changes in release 3.21.28
  1320.     Changes in release 3.21.27
  1321.     Changes in release 3.21.26
  1322.     Changes in release 3.21.25
  1323.     Changes in release 3.21.24
  1324.     Changes in release 3.21.23
  1325.     Changes in release 3.21.22
  1326.     Changes in release 3.21.21a
  1327.     Changes in release 3.21.21
  1328.     Changes in release 3.21.20
  1329.     Changes in release 3.21.19
  1330.     Changes in release 3.21.18
  1331.     Changes in release 3.21.17
  1332.     Changes in release 3.21.16
  1333.     Changes in release 3.21.15
  1334.     Changes in release 3.21.14b
  1335.     Changes in release 3.21.14a
  1336.     Changes in release 3.21.13
  1337.     Changes in release 3.21.12
  1338.     Changes in release 3.21.11
  1339.     Changes in release 3.21.10
  1340.     Changes in release 3.21.9
  1341.     Changes in release 3.21.8
  1342.     Changes in release 3.21.7
  1343.     Changes in release 3.21.6
  1344.     Changes in release 3.21.5
  1345.     Changes in release 3.21.4
  1346.     Changes in release 3.21.3
  1347.     Changes in release 3.21.2
  1348.     Changes in release 3.21.0
  1349.   Changes in release 3.20.x
  1350.     Changes in release 3.20.18
  1351.     Changes in release 3.20.17
  1352.     Changes in release 3.20.16
  1353.     Changes in release 3.20.15
  1354.     Changes in release 3.20.14
  1355.     Changes in release 3.20.13
  1356.     Changes in release 3.20.11
  1357.     Changes in release 3.20.10
  1358.     Changes in release 3.20.9
  1359.     Changes in release 3.20.8
  1360.     Changes in release 3.20.7
  1361.     Changes in release 3.20.6
  1362.     Changes in release 3.20.3
  1363.     Changes in release 3.20.0
  1364.   Changes in release 3.19.x
  1365.     Changes in release 3.19.5
  1366.     Changes in release 3.19.4
  1367.     Changes in release 3.19.3
  1368.   `InnoDB' Change History
  1369.     MySQL/InnoDB-4.0.21, September 10, 2004
  1370.     MySQL/InnoDB-4.1.4, August 31, 2004
  1371.     MySQL/InnoDB-4.1.3, June 28, 2004
  1372.     MySQL/InnoDB-4.1.2, May 30, 2004
  1373.     MySQL/InnoDB-4.0.20, May 18, 2004
  1374.     MySQL/InnoDB-4.0.19, May 4, 2004
  1375.     MySQL/InnoDB-4.0.18, February 13, 2004
  1376.     MySQL/InnoDB-5.0.0, December 24, 2003
  1377.     MySQL/InnoDB-4.0.17, December 17, 2003
  1378.     MySQL/InnoDB-4.1.1, December 4, 2003
  1379.     MySQL/InnoDB-4.0.16, October 22, 2003
  1380.     MySQL/InnoDB-3.23.58, September 15, 2003
  1381.     MySQL/InnoDB-4.0.15, September 10, 2003
  1382.     MySQL/InnoDB-4.0.14, July 22, 2003
  1383.     MySQL/InnoDB-3.23.57, June 20, 2003
  1384.     MySQL/InnoDB-4.0.13, May 20, 2003
  1385.     MySQL/InnoDB-4.1.0, April 3, 2003
  1386.     MySQL/InnoDB-3.23.56, March 17, 2003
  1387.     MySQL/InnoDB-4.0.12, March 18, 2003
  1388.     MySQL/InnoDB-4.0.11, February 25, 2003
  1389.     MySQL/InnoDB-4.0.10, February 4, 2003
  1390.     MySQL/InnoDB-3.23.55, January 24, 2003
  1391.     MySQL/InnoDB-4.0.9, January 14, 2003
  1392.     MySQL/InnoDB-4.0.8, January 7, 2003
  1393.     MySQL/InnoDB-4.0.7, December 26, 2002
  1394.     MySQL/InnoDB-4.0.6, December 19, 2002
  1395.     MySQL/InnoDB-3.23.54, December 12, 2002
  1396.     MySQL/InnoDB-4.0.5, November 18, 2002
  1397.     MySQL/InnoDB-3.23.53, October 9, 2002
  1398.     MySQL/InnoDB-4.0.4, October 2, 2002
  1399.     MySQL/InnoDB-4.0.3, August 28, 2002
  1400.     MySQL/InnoDB-3.23.52, August 16, 2002
  1401.     MySQL/InnoDB-4.0.2, July 10, 2002
  1402.     MySQL/InnoDB-3.23.51, June 12, 2002
  1403.     MySQL/InnoDB-3.23.50, April 23, 2002
  1404.     MySQL/InnoDB-3.23.49, February 17, 2002
  1405.     MySQL/InnoDB-3.23.48, February 9, 2002
  1406.     MySQL/InnoDB-3.23.47, December 28, 2001
  1407.     MySQL/InnoDB-4.0.1, December 23, 2001
  1408.     MySQL/InnoDB-3.23.46, November 30, 2001
  1409.     MySQL/InnoDB-3.23.45, November 23, 2001
  1410.     MySQL/InnoDB-3.23.44, November 2, 2001
  1411.     MySQL/InnoDB-3.23.43, October 4, 2001
  1412.     MySQL/InnoDB-3.23.42, September 9, 2001
  1413.     MySQL/InnoDB-3.23.41, August 13, 2001
  1414.     MySQL/InnoDB-3.23.40, July 16, 2001
  1415.     MySQL/InnoDB-3.23.39, June 13, 2001
  1416.     MySQL/InnoDB-3.23.38, May 12, 2001
  1417.   `MySQL Cluster' Change History
  1418.     MySQL Cluster-4.1.7, (not released yet)
  1419.     MySQL Cluster-4.1.6, 10 Oct 2004
  1420.     MySQL Cluster-4.1.5, 16 Sep 2004
  1421.     MySQL Cluster-4.1.4, 31 Aug 2004
  1422.     MySQL Cluster-5.0.1, 27 Jul 2004
  1423.     MySQL Cluster-4.1.3, 28 Jun 2004
  1424.  
  1425. Porting to Other Systems
  1426.   Debugging a MySQL Server
  1427.     Compiling MySQL for Debugging
  1428.     Creating Trace Files
  1429.     Debugging `mysqld' under `gdb'
  1430.     Using a Stack Trace
  1431.     Using Log Files to Find Cause of Errors in `mysqld'
  1432.     Making a Test Case If You Experience Table Corruption
  1433.   Debugging a MySQL Client
  1434.   The DBUG Package
  1435.   Comments about RTS Threads
  1436.   Differences Between Thread Packages
  1437.  
  1438. Environment Variables
  1439.  
  1440. MySQL Regular Expressions
  1441.  
  1442. GNU General Public License
  1443.  
  1444. MySQL FLOSS License Exception
  1445.  
  1446. SQL Command, Type, and Function Index
  1447.  
  1448. Concept Index
  1449.  
  1450.  
  1451. This is the Reference Manual for the MySQL Database System.  It
  1452. documents MySQL up to Version 4.0.22, but is also applicable for older
  1453. versions of the MySQL software (such as 3.23 or 4.0-production) because
  1454. functional changes are indicated with reference to a version number.
  1455.  
  1456. General Information
  1457. *******************
  1458.  
  1459. The MySQL (R) software delivers a very fast, multi-threaded,
  1460. multi-user, and robust SQL (Structured Query Language) database server.
  1461. MySQL Server is intended for mission-critical, heavy-load production
  1462. systems as well as for embedding into mass-deployed software.  MySQL is
  1463. a registered trademark of MySQL AB.
  1464.  
  1465. The MySQL software is Dual Licensed. Users can choose to use the MySQL
  1466. software as an Open Source/Free Software product under the terms of the
  1467. GNU General Public License (`http://www.fsf.org/licenses/') or can
  1468. purchase a standard commercial license from MySQL AB.  *Note Licensing
  1469. and Support::.
  1470.  
  1471. The MySQL Web site (`http://www.mysql.com/') provides the latest
  1472. information about the MySQL software.
  1473.  
  1474. The following list describes some sections of particular interest in
  1475. this manual:
  1476.  
  1477.    * For information about the company behind the MySQL Database Server,
  1478.      see *Note What is MySQL AB::.
  1479.  
  1480.    * For a discussion about the capabilities of the MySQL Database
  1481.      Server, see *Note Features::.
  1482.  
  1483.    * For installation instructions, see *Note Installing::.
  1484.  
  1485.    * For tips on porting the MySQL Database Software to new
  1486.      architectures or operating systems, see *Note Porting::.
  1487.  
  1488.    * For information about upgrading from a Version 4.0 release, see
  1489.      *Note Upgrading-from-4.0::.
  1490.  
  1491.    * For information about upgrading from a Version 3.23 release, see
  1492.      *Note Upgrading-from-3.23::.
  1493.  
  1494.    * For information about upgrading from a Version 3.22 release, see
  1495.      *Note Upgrading-from-3.22::.
  1496.  
  1497.    * For a tutorial introduction to the MySQL Database Server, see
  1498.      *Note Tutorial::.
  1499.  
  1500.    * For examples of SQL and benchmarking information, see the
  1501.      benchmarking directory (`sql-bench' in the distribution).
  1502.  
  1503.    * For a history of new features and bugfixes, see *Note News::.
  1504.  
  1505.    * For a list of currently known bugs and misfeatures, see *Note
  1506.      Bugs::.
  1507.  
  1508.    * For future plans, see *Note TODO::.
  1509.  
  1510.    * For a list of all the contributors to this project, see *Note
  1511.      Credits::.
  1512.  
  1513. *Important*:
  1514.  
  1515. Reports of errors (often called "bugs"), as well as questions and
  1516. comments, should be sent to the general MySQL mailing list.  *Note
  1517. Mailing-list::.  *Note Bug reports::.
  1518.  
  1519. The `mysqlbug' script should be used to generate bug reports on Unix.
  1520. (Windows distributions contain a file named `mysqlbug.txt' in the base
  1521. directory that can be used as a template for a bug report.)
  1522.  
  1523. For source distributions, the `mysqlbug' script can be found in the
  1524. `scripts' directory. For binary distributions, `mysqlbug' can be found
  1525. in the `bin' directory (`/usr/bin' for the `MySQL-server' RPM package).
  1526.  
  1527. If you have found a sensitive security bug in MySQL Server, please let
  1528. us know immediately by sending an email message to <security@mysql.com>.
  1529.  
  1530. About This Manual
  1531. =================
  1532.  
  1533. This is the Reference Manual for the MySQL Database System.  It
  1534. documents MySQL up to Version 4.0.22, but is also applicable for older
  1535. versions of the MySQL software (such as 3.23 or 4.0-production) because
  1536. functional changes are indicated with reference to a version number.
  1537.  
  1538. Because this manual serves as a reference, it does not provide general
  1539. instruction on SQL or relational database concepts. It also will not
  1540. teach you how to use your operating system or command-line interpreter.
  1541.  
  1542. The MySQL Database Software is under constant development, and the
  1543. Reference Manual is updated frequently as well.  The most recent
  1544. version of the manual is available online in searchable form at
  1545. `http://dev.mysql.com/doc/'.  Other formats also are available,
  1546. including HTML, PDF, and Windows CHM versions.
  1547.  
  1548. The primary document is the Texinfo file.  The HTML version is produced
  1549. automatically using a modified version of `texi2html'.  The plain text
  1550. and Info versions are produced with `makeinfo'.  The PostScript version
  1551. is produced using `texi2dvi' and `dvips'.  The PDF version is produced
  1552. with `pdftex'.
  1553.  
  1554. If you have any suggestions concerning additions or corrections to this
  1555. manual, please send them to the documentation team at <docs@mysql.com>.
  1556.  
  1557. This manual was initially written by David Axmark and Michael "Monty"
  1558. Widenius. It is now maintained by the MySQL Documentation Team,
  1559. consisting of Arjen Lentz, Paul DuBois, and Stefan Hinz.  For the many
  1560. other contributors, see *Note Credits::.
  1561.  
  1562. The copyright (2004) to this manual is owned by the Swedish company
  1563. MySQL AB. *Note Copyright::.  MySQL and the MySQL logo are (registered)
  1564. trademarks of MySQL AB.  Other trademarks and registered trademarks
  1565. referred to in this manual are the property of their respective owners,
  1566. and are used for identification purposes only.
  1567.  
  1568. Conventions Used in This Manual
  1569. -------------------------------
  1570.  
  1571. This manual uses certain typographical conventions:
  1572.  
  1573. `constant'
  1574.      Constant-width font is used for command names and options; SQL
  1575.      statements; database, table, and column names; C and Perl code;
  1576.      and environment variables.  Example: "To see how `mysqladmin'
  1577.      works, invoke it with the `--help' option."
  1578.  
  1579. CONSTANT ITALIC
  1580.      Italic constant-width font is used to indicate variable input for
  1581.      which you should substitute a value of your own choosing.
  1582.  
  1583. `filename'
  1584.      Constant-width font with surrounding quotes is used for filenames
  1585.      and pathnames.  Example: "The distribution is installed under the
  1586.      `/usr/local/' directory."
  1587.  
  1588. `c'
  1589.      Constant-width font with surrounding quotes is also used to
  1590.      indicate character sequences.  Example: "To specify a wildcard,
  1591.      use the `%' character."
  1592.  
  1593. _italic_
  1594.      Italic font is used for emphasis, _like this_.
  1595.  
  1596. *boldface*
  1597.      Boldface font is used in table headings and to convey *especially
  1598.      strong emphasis*.
  1599.  
  1600. When commands are shown that are meant to be executed from within a
  1601. particular program, the program is indicated by a prompt shown before
  1602. the command.  For example, `shell>' indicates a command that you
  1603. execute from your login shell, and `mysql>' indicates a statement that
  1604. you execute from the `mysql' client program:
  1605.  
  1606.      shell> type a shell command here
  1607.      mysql> type a mysql statement here
  1608.  
  1609. The "shell" is your command interpreter. On Unix, this is typically a
  1610. program such as `sh' or `csh'. On Windows, the equivalent program is
  1611. `command.com' or `cmd.exe', typically run in a console window.
  1612.  
  1613. When you enter a command or statement shown in an example, do not type
  1614. the prompt shown in the example.
  1615.  
  1616. Database, table, and column names must often be substituted into
  1617. statements.  To indicate that such substitution is necessary, this
  1618. manual uses DB_NAME, TBL_NAME, and COL_NAME.  For example, you might
  1619. see a statement like this:
  1620.  
  1621.      mysql> SELECT COL_NAME FROM DB_NAME.TBL_NAME;
  1622.  
  1623. This means that if you were to enter a similar statement, you would
  1624. supply your own database, table, and column names, perhaps like this:
  1625.  
  1626.      mysql> SELECT author_name FROM biblio_db.author_list;
  1627.  
  1628. SQL keywords are not case sensitive and may be written in uppercase or
  1629. lowercase.  This manual uses uppercase.
  1630.  
  1631. In syntax descriptions, square brackets (`[' and `]') are used to
  1632. indicate optional words or clauses.  For example, in the following
  1633. statement, `IF EXISTS' is optional:
  1634.  
  1635.      DROP TABLE [IF EXISTS] TBL_NAME
  1636.  
  1637. When a syntax element consists of a number of alternatives, the
  1638. alternatives are separated by vertical bars (`|').  When one member
  1639. from a set of choices _may_ be chosen, the alternatives are listed
  1640. within square brackets (`[' and `]'):
  1641.  
  1642.      TRIM([[BOTH | LEADING | TRAILING] [REMSTR] FROM] STR)
  1643.  
  1644. When one member from a set of choices _must_ be chosen, the
  1645. alternatives are listed within braces (`{' and `}'):
  1646.  
  1647.      {DESCRIBE | DESC} TBL_NAME [COL_NAME | WILD]
  1648.  
  1649. An ellipsis (`...') indicates the omission of a section of a statement,
  1650. typically to provide a shorter version of more complex syntax. For
  1651. example, `INSERT ... SELECT' is shorthand for the form of `INSERT'
  1652. statement that is followed by a `SELECT' statement.
  1653.  
  1654. An ellipsis can also indicate that the preceding syntax element of a
  1655. statement may be repeated. In the following example, multiple
  1656. RESET_OPTION values may be given, with each of those after the first
  1657. preceded by commas:
  1658.  
  1659.      RESET RESET_OPTION [,RESET_OPTION] ...
  1660.  
  1661. Commands for setting shell variables are shown using Bourne shell
  1662. syntax.  For example, the sequence to set an environment variable and
  1663. run a command looks like this in Bourne shell syntax:
  1664.  
  1665.      shell> VARNAME=VALUE SOME_COMMAND
  1666.  
  1667. If you are using `csh' or `tcsh', you must issue commands somewhat
  1668. differently.  You would execute the sequence just shown like this:
  1669.  
  1670.      shell> setenv VARNAME VALUE
  1671.      shell> SOME_COMMAND
  1672.  
  1673. Overview of the MySQL Database Management System
  1674. ================================================
  1675.  
  1676. MySQL, the most popular Open Source SQL database management system, is
  1677. developed, distributed, and supported by MySQL AB.  MySQL AB is a
  1678. commercial company, founded by the MySQL developers.  It is a second
  1679. generation open source company that unites open source values and
  1680. methodology with a successful business model.  *Note What is MySQL AB::.
  1681.  
  1682. The MySQL Web site (`http://www.mysql.com/') provides the latest
  1683. information about MySQL software and MySQL AB.
  1684.  
  1685. MySQL is a database management system.
  1686.      A database is a structured collection of data.  It may be anything
  1687.      from a simple shopping list to a picture gallery or the vast
  1688.      amounts of information in a corporate network.  To add, access,
  1689.      and process data stored in a computer database, you need a
  1690.      database management system such as MySQL Server.  Since computers
  1691.      are very good at handling large amounts of data, database
  1692.      management systems play a central role in computing, as standalone
  1693.      utilities or as parts of other applications.
  1694.  
  1695. MySQL is a relational database management system.
  1696.      A relational database stores data in separate tables rather than
  1697.      putting all the data in one big storeroom.  This adds speed and
  1698.      flexibility.  The SQL part of "MySQL" stands for "Structured Query
  1699.      Language." SQL is the most common standardized language used to
  1700.      access databases and is defined by the ANSI/ISO SQL Standard. The
  1701.      SQL standard has been evolving since 1986 and several versions
  1702.      exist. In this manual, "SQL-92" refers to the standard released in
  1703.      1992, "SQL:1999" refers to the standard released in 1999, and
  1704.      "SQL:2003" refers to the current version of the standard.  We use
  1705.      the phrase "the SQL standard" to mean the current version of the
  1706.      SQL Standard at any time.
  1707.  
  1708. MySQL software is Open Source.
  1709.      Open Source means that it is possible for anyone to use and modify
  1710.      the software.  Anybody can download the MySQL software from the
  1711.      Internet and use it without paying anything.  If you wish, you may
  1712.      study the source code and change it to suit your needs.  The MySQL
  1713.      software uses the GPL (GNU General Public License),
  1714.      `http://www.fsf.org/licenses/', to define what you may and may not
  1715.      do with the software in different situations.  If you feel
  1716.      uncomfortable with the GPL or need to embed MySQL code into a
  1717.      commercial application, you can buy a commercially licensed
  1718.      version from us.  *Note MySQL licenses::.
  1719.  
  1720. The MySQL Database Server is very fast, reliable, and easy to use.
  1721.      If that is what you are looking for, you should give it a try.
  1722.      MySQL Server also has a practical set of features developed in
  1723.      close cooperation with our users.  You can find a performance
  1724.      comparison of MySQL Server with other database managers on our
  1725.      benchmark page.  *Note MySQL Benchmarks::.
  1726.  
  1727.      MySQL Server was originally developed to handle large databases
  1728.      much faster than existing solutions and has been successfully used
  1729.      in highly demanding production environments for several years.
  1730.      Although under constant development, MySQL Server today offers a
  1731.      rich and useful set of functions.  Its connectivity, speed, and
  1732.      security make MySQL Server highly suited for accessing databases
  1733.      on the Internet.
  1734.  
  1735. MySQL Server works in client/server or embedded systems.
  1736.      The MySQL Database Software is a client/server system that consists
  1737.      of a multi-threaded SQL server that supports different backends,
  1738.      several different client programs and libraries, administrative
  1739.      tools, and a wide range of application programming interfaces
  1740.      (APIs).
  1741.  
  1742.      We also provide MySQL Server as an embedded multi-threaded library
  1743.      that you can link into your application to get a smaller, faster,
  1744.      easier-to-manage product.
  1745.  
  1746. A large amount of contributed MySQL software is available.
  1747.      It is very likely that you will find that your favorite
  1748.      application or language already supports the MySQL Database Server.
  1749.  
  1750. The official way to pronounce "MySQL" is "My Ess Que Ell" (not "my
  1751. sequel"), but we don't mind if you pronounce it as "my sequel" or in
  1752. some other localized way.
  1753.  
  1754. History of MySQL
  1755. ----------------
  1756.  
  1757. We started out with the intention of using `mSQL' to connect to our
  1758. tables using our own fast low-level (ISAM) routines. However, after some
  1759. testing, we came to the conclusion that `mSQL' was not fast enough or
  1760. flexible enough for our needs.  This resulted in a new SQL interface to
  1761. our database but with almost the same API interface as `mSQL'.  This
  1762. API was designed to allow third-party code that was written for use
  1763. with `mSQL' to be ported easily for use with MySQL.
  1764.  
  1765. The derivation of the name MySQL is not clear.  Our base directory and
  1766. a large number of our libraries and tools have had the prefix "my" for
  1767. well over 10 years.  However, co-founder Monty Widenius's daughter is
  1768. also named My.  Which of the two gave its name to MySQL is still a
  1769. mystery, even for us.
  1770.  
  1771. The name of the MySQL Dolphin (our logo) is "Sakila," which was chosen
  1772. by the founders of MySQL AB from a huge list of names suggested by users
  1773. in our "Name the Dolphin" contest. The winning name was submitted by
  1774. Ambrose Twebaze, an Open Source software developer from Swaziland,
  1775. Africa.  According to Ambrose, the name Sakila has its roots in
  1776. SiSwati, the local language of Swaziland. Sakila is also the name of a
  1777. town in Arusha, Tanzania, near Ambrose's country of origin, Uganda.
  1778.  
  1779. The Main Features of MySQL
  1780. --------------------------
  1781.  
  1782. The following list describes some of the important characteristics of
  1783. the MySQL Database Software. See also *Note Roadmap:: for more
  1784. information about current and upcoming features.
  1785.  
  1786. Internals and Portability
  1787.         * Written in C and C++.
  1788.  
  1789.         * Tested with a broad range of different compilers.
  1790.  
  1791.         * Works on many different platforms.  *Note Which OS::.
  1792.  
  1793.         * Uses GNU Automake, Autoconf, and Libtool for portability.
  1794.  
  1795.         * APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and
  1796.           Tcl are available.  *Note MySQL APIs::.
  1797.  
  1798.         * Fully multi-threaded using kernel threads.  It can easily use
  1799.           multiple CPUs if they are available.
  1800.  
  1801.         * Provides transactional and non-transactional storage engines.
  1802.  
  1803.         * Uses very fast B-tree disk tables (`MyISAM') with index
  1804.           compression.
  1805.  
  1806.         * Relatively easy to add another storage engine. This is useful
  1807.           if you want to add an SQL interface to an in-house database.
  1808.  
  1809.         * A very fast thread-based memory allocation system.
  1810.  
  1811.         * Very fast joins using an optimized one-sweep multi-join.
  1812.  
  1813.         * In-memory hash tables, which are used as temporary tables.
  1814.  
  1815.         * SQL functions are implemented using a highly optimized class
  1816.           library and should be as fast as possible.  Usually there is
  1817.           no memory allocation at all after query initialization.
  1818.  
  1819.         * The MySQL code is tested with Purify (a commercial memory
  1820.           leakage detector) as well as with Valgrind, a GPL tool
  1821.           (`http://developer.kde.org/~sewardj/').
  1822.  
  1823.         * The server is available as a separate program for use in a
  1824.           client/server networked environment.  It is also available as
  1825.           a library that can be embedded (linked) into standalone
  1826.           applications. Such applications can be used in isolation or
  1827.           in environments where no network is available.
  1828.  
  1829. Column Types
  1830.         * Many column types: signed/unsigned integers 1, 2, 3, 4, and 8
  1831.           bytes long, `FLOAT', `DOUBLE', `CHAR', `VARCHAR', `TEXT',
  1832.           `BLOB', `DATE', `TIME', `DATETIME', `TIMESTAMP', `YEAR',
  1833.           `SET', `ENUM', and OpenGIS spatial types.  *Note Column
  1834.           types::.
  1835.  
  1836.         * Fixed-length and variable-length records.
  1837.  
  1838. Statements and Functions
  1839.         * Full operator and function support in the `SELECT' and `WHERE'
  1840.           clauses of queries.  For example:
  1841.  
  1842.                mysql> SELECT CONCAT(first_name, ' ', last_name)
  1843.                    -> FROM citizen
  1844.                    -> WHERE income/dependents > 10000 AND age > 30;
  1845.  
  1846.         * Full support for SQL `GROUP BY' and `ORDER BY' clauses.
  1847.           Support for group functions (`COUNT()', `COUNT(DISTINCT ...)',
  1848.           `AVG()', `STD()', `SUM()', `MAX()', `MIN()', and
  1849.           `GROUP_CONCAT()').
  1850.  
  1851.         * Support for `LEFT OUTER JOIN' and `RIGHT OUTER JOIN' with
  1852.           both standard SQL and ODBC syntax.
  1853.  
  1854.         * Support for aliases on tables and columns as required by
  1855.           standard SQL.
  1856.  
  1857.         * `DELETE', `INSERT', `REPLACE', and `UPDATE' return the number
  1858.           of rows that were changed (affected).  It is possible to
  1859.           return the number of rows matched instead by setting a flag
  1860.           when connecting to the server.
  1861.  
  1862.         * The MySQL-specific `SHOW' command can be used to retrieve
  1863.           information about databases, tables, and indexes.  The
  1864.           `EXPLAIN' command can be used to determine how the optimizer
  1865.           resolves a query.
  1866.  
  1867.         * Function names do not clash with table or column names.  For
  1868.           example, `ABS' is a valid column name.  The only restriction
  1869.           is that for a function call, no spaces are allowed between
  1870.           the function name and the `(' that follows it.  *Note
  1871.           Reserved words::.
  1872.  
  1873.         * You can mix tables from different databases in the same query
  1874.           (as of MySQL 3.22).
  1875.  
  1876. Security
  1877.         * A privilege and password system that is very flexible and
  1878.           secure, and that allows host-based verification.  Passwords
  1879.           are secure because all password traffic is encrypted when you
  1880.           connect to a server.
  1881.  
  1882. Scalability and Limits
  1883.         * Handles large databases.  We use MySQL Server with databases
  1884.           that contain 50 million records. We also know of users who
  1885.           use MySQL Server with 60,000 tables and about 5,000,000,000
  1886.           rows.
  1887.  
  1888.         * Up to 64 indexes per table are allowed (32 before MySQL
  1889.           4.1.2).  Each index may consist of 1 to 16 columns or parts
  1890.           of columns.  The maximum index width is 1000 bytes (500
  1891.           before MySQL 4.1.2).  An index may use a prefix of a column
  1892.           for `CHAR', `VARCHAR', `BLOB', or `TEXT' column types.
  1893.  
  1894. Connectivity
  1895.         * Clients can connect to the MySQL server using TCP/IP sockets
  1896.           on any platform.  On Windows systems in the NT family (NT,
  1897.           2000, or XP), clients can connect using named pipes. On Unix
  1898.           systems, clients can connect using Unix domain socket files.
  1899.  
  1900.         * The Connector/ODBC (MyODBC) interface provides MySQL support
  1901.           for client programs that use ODBC (Open Database
  1902.           Connectivity) connections.  For example, you can use MS
  1903.           Access to connect to your MySQL server.  Clients can be run
  1904.           on Windows or Unix.  MyODBC source is available.  All ODBC
  1905.           2.5 functions are supported, as are many others.  *Note ODBC
  1906.           Connector::.
  1907.  
  1908.         * The Connector/J interface provides MySQL support for Java
  1909.           client programs that use JDBC connections.  Clients can be
  1910.           run on Windows or Unix.  Connector/J source is available.
  1911.           *Note Java Connector::.
  1912.  
  1913. Localization
  1914.         * The server can provide error messages to clients in many
  1915.           languages.  *Note Languages::.
  1916.  
  1917.         * Full support for several different character sets, including
  1918.           `latin1' (ISO-8859-1), `german', `big5', `ujis', and more.
  1919.           For example, the Scandinavian characters `a^', `a"' and `o"'
  1920.           are allowed in table and column names.  Unicode support is
  1921.           available as of MySQL 4.1.
  1922.  
  1923.         * All data is saved in the chosen character set.  All
  1924.           comparisons for normal string columns are case-insensitive.
  1925.  
  1926.         * Sorting is done according to the chosen character set (using
  1927.           Swedish collation by default).  It is possible to change this
  1928.           when the MySQL server is started.  To see an example of very
  1929.           advanced sorting, look at the Czech sorting code.  MySQL
  1930.           Server supports many different character sets that can be
  1931.           specified at compile time and runtime.
  1932.  
  1933. Clients and Tools
  1934.         * The MySQL server has built-in support for SQL statements to
  1935.           check, optimize, and repair tables.  These statements are
  1936.           available from the command line through the `mysqlcheck'
  1937.           client. MySQL also includes `myisamchk', a very fast
  1938.           command-line utility for performing these operations on
  1939.           `MyISAM' tables.  *Note MySQL Database Administration::.
  1940.  
  1941.         * All MySQL programs can be invoked with the `--help' or `-?'
  1942.           options to obtain online assistance.
  1943.  
  1944. MySQL Stability
  1945. ---------------
  1946.  
  1947. This section addresses the questions, "_How stable is MySQL Server?_"
  1948. and, "_Can I depend on MySQL Server in this project?_" We will try to
  1949. clarify these issues and answer some important questions that concern
  1950. many potential users. The information in this section is based on data
  1951. gathered from the mailing lists, which are very active in identifying
  1952. problems as well as reporting types of use.
  1953.  
  1954. The original code stems back to the early 1980s. It provides a stable
  1955. code base, and the `ISAM' table format used by the original storage
  1956. engine remains backward-compatible.  At TcX, the predecessor of MySQL
  1957. AB, MySQL code has worked in projects since mid-1996, without any
  1958. problems.  When the MySQL Database Software initially was released to a
  1959. wider public, our new users quickly found some pieces of untested code.
  1960. Each new release since then has had fewer portability problems, even
  1961. though each new release has also had many new features.
  1962.  
  1963. Each release of the MySQL Server has been usable. Problems have occurred
  1964. only when users try code from the "gray zones."  Naturally, new users
  1965. don't know what the gray zones are; this section therefore attempts to
  1966. document those areas that are currently known.  The descriptions mostly
  1967. deal with Version 3.23, 4.0 and 4.1 of MySQL Server.  All known and
  1968. reported bugs are fixed in the latest version, with the exception of
  1969. those listed in the bugs section, which are design-related.  *Note
  1970. Bugs::.
  1971.  
  1972. The MySQL Server design is multi-layered with independent modules.
  1973. Some of the newer modules are listed here with an indication of how
  1974. well-tested each of them is:
  1975.  
  1976. Replication (Stable)
  1977.      Large groups of servers using replication are in production use,
  1978.      with good results. Work on enhanced replication features is
  1979.      continuing in MySQL 5.x.
  1980.  
  1981. `InnoDB' tables (Stable)
  1982.      The `InnoDB' transactional storage engine has been declared stable
  1983.      in the MySQL 3.23 tree, starting from version 3.23.49.  `InnoDB'
  1984.      is being used in large, heavy-load production systems.
  1985.  
  1986. `BDB' tables (Stable)
  1987.      The `Berkeley DB' code is very stable, but we are still improving
  1988.      the `BDB' transactional storage engine interface in MySQL Server.
  1989.  
  1990. Full-text searches (Stable)
  1991.      Full-text searching is widely used.  Important feature
  1992.      enhancements were added in MySQL 4.0 and 4.1.
  1993.  
  1994. `MyODBC' 3.51 (Stable)
  1995.      `MyODBC' 3.51 uses ODBC SDK 3.51 and is in wide production use.
  1996.      Some issues brought up appear to be application-related and
  1997.      independent of the ODBC driver or underlying database server.
  1998.  
  1999. How Big MySQL Tables Can Be
  2000. ---------------------------
  2001.  
  2002. MySQL 3.22 had a 4GB (4 gigabyte) limit on table size. With the
  2003. `MyISAM' storage engine in MySQL 3.23, the maximum table size was
  2004. increased to 8 million terabytes (2 ^ 63 bytes). With this larger
  2005. allowed table size, the maximum effective table size for MySQL
  2006. databases now usually is determined by operating system constraints on
  2007. file sizes, not by MySQL internal limits.
  2008.  
  2009. The `InnoDB' storage engine maintains `InnoDB' tables within a
  2010. tablespace that can be created from several files. This allows a table
  2011. to exceed the maximum individual file size. The tablespace can include
  2012. raw disk partitions, which allows extremely large tables. The maximum
  2013. tablespace size is 64TB.
  2014.  
  2015. The following table lists some examples of operating system file-size
  2016. limits:
  2017.  
  2018. *Operating System*     *File-size Limit*
  2019. Linux-Intel 32-bit     2GB, much more when using LFS
  2020. Linux-Alpha            8TB (?)
  2021. Solaris 2.5.1          2GB (4GB possible with patch)
  2022. Solaris 2.6            4GB (can be changed with flag)
  2023. Solaris 2.7 Intel      4GB
  2024. Solaris 2.7            512GB
  2025. UltraSPARC             
  2026. NetWare w/NSS          8TB
  2027. filesystem             
  2028.  
  2029. On Linux 2.2, you can get `MyISAM' tables larger than 2GB in size by
  2030. using the Large File Support (LFS) patch for the ext2 filesystem. On
  2031. Linux 2.4, patches also exist for ReiserFS to get support for big
  2032. files. Most current Linux distributions are based on kernel 2.4 and
  2033. already include all the required LFS patches. However, the maximum
  2034. available file size still depends on several factors, one of them being
  2035. the filesystem used to store MySQL tables.
  2036.  
  2037. For a detailed overview about LFS in Linux, have a look at Andreas
  2038. Jaeger's `Large File Support in Linux' page at
  2039. `http://www.suse.de/~aj/linux_lfs.html'.
  2040.  
  2041. By default, MySQL creates `MyISAM' tables with an internal structure
  2042. that allows a maximum size of about 4GB.  You can check the maximum
  2043. table size for a table with the `SHOW TABLE STATUS' statement or with
  2044. `myisamchk -dv TBL_NAME'.  *Note `SHOW': SHOW.
  2045.  
  2046. If you need a `MyISAM' table that will be larger than 4GB in size (and
  2047. your operating system supports large files), the `CREATE TABLE'
  2048. statement allows `AVG_ROW_LENGTH' and `MAX_ROWS' options.  *Note
  2049. `CREATE TABLE': CREATE TABLE.  You can also change these options with
  2050. `ALTER TABLE' after the table has been created, to increase the table's
  2051. maximum allowable size.  *Note `ALTER TABLE': ALTER TABLE.
  2052.  
  2053. Other ways to work around file-size limits for `MyISAM' tables are as
  2054. follows:
  2055.  
  2056.    * If your large table is read-only, you can use `myisampack' to
  2057.      compress it.  `myisampack' usually compresses a table by at least
  2058.      50%, so you can have, in effect, much bigger tables.  `myisampack'
  2059.      also can merge multiple tables into a single table.  *Note
  2060.      `myisampack': myisampack.
  2061.  
  2062.    * Another way to get around the operating system file limit for
  2063.      `MyISAM' data files is by using the `RAID' options.  *Note `CREATE
  2064.      TABLE': CREATE TABLE.
  2065.  
  2066.    * MySQL includes a `MERGE' library that allows you to handle a
  2067.      collection of `MyISAM' tables that have identical structure as a
  2068.      single `MERGE' table.  *Note `MERGE' tables: MERGE.
  2069.  
  2070.  
  2071. Year 2000 Compliance
  2072. --------------------
  2073.  
  2074. The MySQL Server itself has no problems with Year 2000 (Y2K) compliance:
  2075.  
  2076.    * MySQL Server uses Unix time functions that handle dates into the
  2077.      year `2037' for `TIMESTAMP' values. For `DATE' and `DATETIME'
  2078.      values, dates through the year `9999' are accepted.
  2079.  
  2080.    * All MySQL date functions are implemented in one source file,
  2081.      `sql/time.cc', and are coded very carefully to be year 2000-safe.
  2082.  
  2083.    * In MySQL 3.22 and later, the `YEAR' column type can store years
  2084.      `0' and `1901' to `2155' in one byte and display them using two or
  2085.      four digits.  All two-digit years are considered to be in the range
  2086.      `1970' to `2069', which means that if you store `01' in a `YEAR'
  2087.      column, MySQL Server treats it as `2001'.
  2088.  
  2089. The following simple demonstration illustrates that MySQL Server has no
  2090. problems with `DATE' or `DATETIME' values through the year 9999, and no
  2091. problems with `TIMESTAMP' values until after the year 2030:
  2092.  
  2093.      mysql> DROP TABLE IF EXISTS y2k;
  2094.      Query OK, 0 rows affected (0.01 sec)
  2095.      
  2096.      mysql> CREATE TABLE y2k (date DATE,
  2097.          ->                   date_time DATETIME,
  2098.          ->                   time_stamp TIMESTAMP);
  2099.      Query OK, 0 rows affected (0.01 sec)
  2100.      
  2101.      mysql> INSERT INTO y2k VALUES
  2102.          -> ('1998-12-31','1998-12-31 23:59:59',19981231235959),
  2103.          -> ('1999-01-01','1999-01-01 00:00:00',19990101000000),
  2104.          -> ('1999-09-09','1999-09-09 23:59:59',19990909235959),
  2105.          -> ('2000-01-01','2000-01-01 00:00:00',20000101000000),
  2106.          -> ('2000-02-28','2000-02-28 00:00:00',20000228000000),
  2107.          -> ('2000-02-29','2000-02-29 00:00:00',20000229000000),
  2108.          -> ('2000-03-01','2000-03-01 00:00:00',20000301000000),
  2109.          -> ('2000-12-31','2000-12-31 23:59:59',20001231235959),
  2110.          -> ('2001-01-01','2001-01-01 00:00:00',20010101000000),
  2111.          -> ('2004-12-31','2004-12-31 23:59:59',20041231235959),
  2112.          -> ('2005-01-01','2005-01-01 00:00:00',20050101000000),
  2113.          -> ('2030-01-01','2030-01-01 00:00:00',20300101000000),
  2114.          -> ('2040-01-01','2040-01-01 00:00:00',20400101000000),
  2115.          -> ('9999-12-31','9999-12-31 23:59:59',99991231235959);
  2116.      Query OK, 14 rows affected (0.01 sec)
  2117.      Records: 14  Duplicates: 0  Warnings: 2
  2118.      
  2119.      mysql> SELECT * FROM y2k;
  2120.      +------------+---------------------+----------------+
  2121.      | date       | date_time           | time_stamp     |
  2122.      +------------+---------------------+----------------+
  2123.      | 1998-12-31 | 1998-12-31 23:59:59 | 19981231235959 |
  2124.      | 1999-01-01 | 1999-01-01 00:00:00 | 19990101000000 |
  2125.      | 1999-09-09 | 1999-09-09 23:59:59 | 19990909235959 |
  2126.      | 2000-01-01 | 2000-01-01 00:00:00 | 20000101000000 |
  2127.      | 2000-02-28 | 2000-02-28 00:00:00 | 20000228000000 |
  2128.      | 2000-02-29 | 2000-02-29 00:00:00 | 20000229000000 |
  2129.      | 2000-03-01 | 2000-03-01 00:00:00 | 20000301000000 |
  2130.      | 2000-12-31 | 2000-12-31 23:59:59 | 20001231235959 |
  2131.      | 2001-01-01 | 2001-01-01 00:00:00 | 20010101000000 |
  2132.      | 2004-12-31 | 2004-12-31 23:59:59 | 20041231235959 |
  2133.      | 2005-01-01 | 2005-01-01 00:00:00 | 20050101000000 |
  2134.      | 2030-01-01 | 2030-01-01 00:00:00 | 20300101000000 |
  2135.      | 2040-01-01 | 2040-01-01 00:00:00 | 00000000000000 |
  2136.      | 9999-12-31 | 9999-12-31 23:59:59 | 00000000000000 |
  2137.      +------------+---------------------+----------------+
  2138.      14 rows in set (0.00 sec)
  2139.  
  2140. The final two `TIMESTAMP' column values are zero because the year
  2141. values (`2040', `9999') exceed the `TIMESTAMP' maximum.  The
  2142. `TIMESTAMP' data type, which is used to store the current time,
  2143. supports values that range from `19700101000000' to `20300101000000' on
  2144. 32-bit machines (signed value).  On 64-bit machines, `TIMESTAMP'
  2145. handles values up to `2106' (unsigned value).
  2146.  
  2147. Although MySQL Server itself is Y2K-safe, you may run into problems if
  2148. you use it with applications that are not Y2K-safe.  For example, many
  2149. old applications store or manipulate years using two-digit values
  2150. (which are ambiguous) rather than four-digit values.  This problem may
  2151. be compounded by applications that use values such as `00' or `99' as
  2152. "missing" value indicators.  Unfortunately, these problems may be
  2153. difficult to fix because different applications may be written by
  2154. different programmers, each of whom may use a different set of
  2155. conventions and date-handling functions.
  2156.  
  2157. Thus, even though MySQL Server has no Y2K problems, it is the
  2158. application's responsibility to provide unambiguous input.  See *Note
  2159. Y2K issues:: for MySQL Server's rules for dealing with ambiguous date
  2160. input data that contains two-digit year values.
  2161.  
  2162. Overview of MySQL AB
  2163. ====================
  2164.  
  2165. MySQL AB is the company of the MySQL founders and main developers.
  2166. MySQL AB was originally established in Sweden by David Axmark, Allan
  2167. Larsson, and Michael "Monty" Widenius.
  2168.  
  2169. The developers of the MySQL server are all employed by the company.  We
  2170. are a virtual organization with people in a dozen countries around the
  2171. world. We communicate extensively over the Internet every day with one
  2172. another and with our users, supporters, and partners.
  2173.  
  2174. We are dedicated to developing the MySQL database software and
  2175. promoting it to new users. MySQL AB owns the copyright to the MySQL
  2176. source code, the MySQL logo and (registered) trademark, and this
  2177. manual. *Note What-is::.
  2178.  
  2179. The MySQL core values show our dedication to MySQL and Open Source.
  2180.  
  2181. These core values direct how MySQL AB works with the MySQL server
  2182. software:
  2183.  
  2184.    * To be the best and the most widely used database in the world
  2185.  
  2186.    * To be available and affordable by all
  2187.  
  2188.    * To be easy to use
  2189.  
  2190.    * To be continuously improved while remaining fast and safe
  2191.  
  2192.    * To be fun to use and improve
  2193.  
  2194.    * To be free from bugs
  2195.  
  2196. These are the core values of the company MySQL AB and its employees:
  2197.  
  2198.    * We subscribe to the Open Source philosophy and support the Open
  2199.      Source community
  2200.  
  2201.    * We aim to be good citizens
  2202.  
  2203.    * We prefer partners that share our values and mindset
  2204.  
  2205.    * We answer email and provide support
  2206.  
  2207.    * We are a virtual company, networking with others
  2208.  
  2209.    * We work against software patents
  2210.  
  2211. The MySQL Web site (`http://www.mysql.com/') provides the latest
  2212. information about MySQL and MySQL AB.
  2213.  
  2214. By the way, the "AB" part of the company name is the acronym for the
  2215. Swedish "aktiebolag," or "stock company." It translates to "MySQL,
  2216. Inc." In fact, MySQL, Inc. and MySQL GmbH are examples of MySQL AB
  2217. subsidiaries. They are located in the US and Germany, respectively.
  2218.  
  2219. The Business Model and Services of MySQL AB
  2220. -------------------------------------------
  2221.  
  2222. One of the most common questions we encounter is, "_How can you make a
  2223. living from something you give away for free?_" This is how:
  2224.  
  2225.    * MySQL AB makes money on support, services, commercial licenses,
  2226.      and royalties.
  2227.  
  2228.    * We use these revenues to fund product development and to expand
  2229.      the MySQL business.
  2230.  
  2231. The company has been profitable since its inception. In October 2001,
  2232. we accepted venture financing from leading Scandinavian investors and a
  2233. handful of business angels. This investment is used to solidify our
  2234. business model and build a basis for sustainable growth.
  2235.  
  2236. Support
  2237. .......
  2238.  
  2239. MySQL AB is run and owned by the founders and main developers of the
  2240. MySQL database. The developers are committed to providing support to
  2241. customers and other users in order to stay in touch with their needs
  2242. and problems. All our support is provided by qualified developers.
  2243. Really tricky questions are answered by Michael "Monty" Widenius,
  2244. principal author of the MySQL Server.
  2245.  
  2246. Paying customers receive high-quality support directly from MySQL AB.
  2247. MySQL AB also provides the MySQL mailing lists as a community resource
  2248. where anyone may ask questions.
  2249.  
  2250. For more information and ordering support at various levels, see *Note
  2251. Licensing and Support::.
  2252.  
  2253. Training and Certification
  2254. ..........................
  2255.  
  2256. MySQL AB delivers MySQL and related training worldwide.  We offer both
  2257. open courses and in-house courses tailored to the specific needs of
  2258. your company. MySQL Training is also available through our partners,
  2259. the Authorized MySQL Training Centers.
  2260.  
  2261. Our training material uses the same sample databases used in our
  2262. documentation and our sample applications, and is always updated to
  2263. reflect the latest MySQL version. Our trainers are backed by the
  2264. development team to guarantee the quality of the training and the
  2265. continuous development of the course material. This also ensures that
  2266. no questions raised during the courses remain unanswered.
  2267.  
  2268. Attending our training courses will enable you to achieve your MySQL
  2269. application goals. You will also:
  2270.    * Save time
  2271.  
  2272.    * Improve the performance of your applications
  2273.  
  2274.    * Reduce or eliminate the need for additional hardware, decreasing
  2275.      cost
  2276.  
  2277.    * Enhance security.
  2278.  
  2279.    * Increase customer and co-worker satisfaction
  2280.  
  2281.    * Prepare yourself for MySQL Certification
  2282.  
  2283. If you are interested in our training as a potential participant or as
  2284. a training partner, please visit the training section at
  2285. `http://www.mysql.com/training/', or send email to <training@mysql.com>.
  2286.  
  2287. For details about the MySQL Certification Program, please see
  2288. `http://www.mysql.com/certification/'.
  2289.  
  2290. Consulting
  2291. ..........
  2292.  
  2293. MySQL AB and its Authorized Partners offer consulting services to users
  2294. of MySQL Server and to those who embed MySQL Server in their own
  2295. software, all over the world.
  2296.  
  2297. Our consultants can help you design and tune your databases, construct
  2298. efficient queries, tune your platform for optimal performance, resolve
  2299. migration issues, set up replication, build robust transactional
  2300. applications, and more.  We also help customers embed MySQL Server in
  2301. their products and applications for large-scale deployment.
  2302.  
  2303. Our consultants work in close collaboration with our development team,
  2304. which ensures the technical quality of our professional services.
  2305. Consulting assignments range from two-day power-start sessions to
  2306. projects that span weeks and months. Our expertise covers not only
  2307. MySQL Server, it also extends into programming and scripting languages
  2308. such as PHP, Perl, and more.
  2309.  
  2310. If you are interested in our consulting services or want to become a
  2311. consulting partner, please visit the consulting section of our Web site
  2312. at `http://www.mysql.com/consulting/' or contact our consulting staff
  2313. at <consulting@mysql.com>.
  2314.  
  2315. Commercial Licenses
  2316. ...................
  2317.  
  2318. The MySQL database is released under the GNU General Public License
  2319. (GPL).  This means that the MySQL software can be used free of charge
  2320. under the GPL. If you do not want to be bound by the GPL terms (such as
  2321. the requirement that your application must also be GPL), you may
  2322. purchase a commercial license for the same product from MySQL AB; see
  2323. `https://order.mysql.com/'.  Since MySQL AB owns the copyright to the
  2324. MySQL source code, we are able to employ Dual Licensing, which means
  2325. that the same product is available under GPL and under a commercial
  2326. license. This does not in any way affect the Open Source commitment of
  2327. MySQL AB. For details about when a commercial license is required,
  2328. please see *Note MySQL licenses::.
  2329.  
  2330. We also sell commercial licenses of third-party Open Source GPL
  2331. software that adds value to MySQL Server. A good example is the
  2332. `InnoDB' transactional storage engine that offers `ACID' support,
  2333. row-level locking, crash recovery, multi-versioning, foreign key
  2334. support, and more. *Note InnoDB::.
  2335.  
  2336. Partnering
  2337. ..........
  2338.  
  2339. MySQL AB has a worldwide partner program that covers training courses,
  2340. consulting and support, publications, plus reselling and distributing
  2341. MySQL and related products. MySQL AB Partners get visibility on the
  2342. `http://www.mysql.com/' Web site and the right to use special versions
  2343. of the MySQL (registered) trademarks to identify their products and
  2344. promote their business.
  2345.  
  2346. If you are interested in becoming a MySQL AB Partner, please email
  2347. <partner@mysql.com>.
  2348.  
  2349. The word MySQL and the MySQL dolphin logo are (registered) trademarks
  2350. of MySQL AB. *Note MySQL AB Logos and Trademarks::.  These trademarks
  2351. represent a significant value that the MySQL founders have built over
  2352. the years.
  2353.  
  2354. The MySQL Web site (`http://www.mysql.com/') is popular among
  2355. developers and users. In December 2003, we served 16 million page views.
  2356. Our visitors represent a group that makes purchase decisions and
  2357. recommendations for both software and hardware. Twelve percent of our
  2358. visitors authorize purchase decisions, and only nine percent have no
  2359. involvement at all in purchase decisions. More than 65% have made one or
  2360. more online business purchases within the last half-year, and 70% plan
  2361. to make one in the next few months.
  2362.  
  2363. Contact Information
  2364. -------------------
  2365.  
  2366. The MySQL Web site (`http://www.mysql.com/') provides the latest
  2367. information about MySQL and MySQL AB.
  2368.  
  2369. For press services and inquiries not covered in our news releases
  2370. (`http://www.mysql.com/news-and-events/'), please send email to
  2371. <press@mysql.com>.
  2372.  
  2373. If you have a support contract with MySQL AB, you will get timely,
  2374. precise answers to your technical questions about the MySQL software.
  2375. For more information, see *Note Support::.  On our Web site, see
  2376. `http://www.mysql.com/support/', or send email to <sales@mysql.com>.
  2377.  
  2378. For information about MySQL training, please visit the training section
  2379. at `http://www.mysql.com/training/', or send email to
  2380. <training@mysql.com>.  *Note Business Services Training::.
  2381.  
  2382. For information on the MySQL Certification Program, please see
  2383. `http://www.mysql.com/certification/'.  *Note Business Services
  2384. Training::.
  2385.  
  2386. If you're interested in consulting, please visit the consulting section
  2387. of our Web site at `http://www.mysql.com/consulting/', or send email to
  2388. <consulting@mysql.com>.  *Note Business Services Consulting::.
  2389.  
  2390. Commercial licenses may be purchased online at
  2391. `https://order.mysql.com/'. There you will also find information on how
  2392. to fax your purchase order to MySQL AB. More information about
  2393. licensing can be found at `http://www.mysql.com/products/licensing/'.
  2394. If you have questions regarding licensing or you want a quote for
  2395. high-volume licensing, please fill in the contact form on our Web site
  2396. (`http://www.mysql.com/'), or send email to <licensing@mysql.com> (for
  2397. licensing questions) or to <sales@mysql.com> (for sales inquiries).
  2398. *Note MySQL licenses::.
  2399.  
  2400. If you represent a business that is interested in partnering with MySQL
  2401. AB, please send email to <partner@mysql.com>.  *Note Business Services
  2402. Partnering::.
  2403.  
  2404. For more information on the MySQL trademark policy, refer to
  2405. `http://www.mysql.com/company/trademark.html', or send email to
  2406. <trademark@mysql.com>.  *Note MySQL AB Logos and Trademarks::.
  2407.  
  2408. If you are interested in any of the MySQL AB jobs listed in our jobs
  2409. section (`http://www.mysql.com/company/jobs/'), please send email to
  2410. <jobs@mysql.com>.  Please do not send your CV as an attachment, but
  2411. rather as plain text at the end of your email message.
  2412.  
  2413. For general discussion among our many users, please direct your
  2414. attention to the appropriate mailing list.  *Note Questions::.
  2415.  
  2416. Reports of errors (often called "bugs"), as well as questions and
  2417. comments, should be sent to the general MySQL mailing list.  *Note
  2418. Mailing-list::.  If you have found a sensitive security bug in MySQL
  2419. Server, please let us know immediately by sending email to
  2420. <security@mysql.com>.  *Note Bug reports::.
  2421.  
  2422. If you have benchmark results that we can publish, please contact us
  2423. via email at <benchmarks@mysql.com>.
  2424.  
  2425. If you have suggestions concerning additions or corrections to this
  2426. manual, please send them to the documentation team via email at
  2427. <docs@mysql.com>.
  2428.  
  2429. For questions or comments about the workings or content of the MySQL
  2430. Web site (`http://www.mysql.com/'), please send email to
  2431. <webmaster@mysql.com>.
  2432.  
  2433. MySQL AB has a privacy policy, which can be read at
  2434. `http://www.mysql.com/company/privacy.html'.  For any queries regarding
  2435. this policy, please send email to <privacy@mysql.com>.
  2436.  
  2437. For all other inquiries, please send email to <info@mysql.com>.
  2438.  
  2439. MySQL Support and Licensing
  2440. ===========================
  2441.  
  2442. This section describes MySQL support and licensing arrangements.
  2443.  
  2444. Support Offered by MySQL AB
  2445. ---------------------------
  2446.  
  2447. Technical support from MySQL AB means individualized answers to your
  2448. unique problems direct from the software engineers who code the MySQL
  2449. database engine.
  2450.  
  2451. We try to take a broad and inclusive view of technical support. Almost
  2452. any problem involving MySQL software is important to us if it's
  2453. important to you.  Typically customers seek help on how to get
  2454. different commands and utilities to work, remove performance
  2455. bottlenecks, restore crashed systems, understand the impact of
  2456. operating system or networking issues on MySQL, set up best practices
  2457. for backup and recovery, utilize APIs, and so on.  Our support covers
  2458. only the MySQL server and our own utilities, not third-party products
  2459. that access the MySQL server, although we try to help with these where
  2460. we can.
  2461.  
  2462. Detailed information about our various support options is given at
  2463. `http://www.mysql.com/support/', where support contracts can also be
  2464. ordered online.  To contact our sales staff, send email to
  2465. <sales@mysql.com>.
  2466.  
  2467. Technical support is like life insurance. You can live happily without
  2468. it for years. However, when your hour arrives, it becomes critically
  2469. important, but it's too late to buy it.  If you use MySQL Server for
  2470. important applications and encounter sudden difficulties, it may be too
  2471. time-consuming to figure out all the answers yourself. You may need
  2472. immediate access to the most experienced MySQL troubleshooters
  2473. available, those employed by MySQL AB.
  2474.  
  2475. Copyrights and Licenses Used by MySQL
  2476. -------------------------------------
  2477.  
  2478. MySQL AB owns the copyright to the MySQL source code, the MySQL logos
  2479. and (registered) trademarks, and this manual.  *Note What is MySQL AB::.
  2480. Several different licenses are relevant to the MySQL distribution:
  2481.  
  2482.   1. All the MySQL-specific source in the server, the `mysqlclient'
  2483.      library and the client, as well as the GNU `readline' library, are
  2484.      covered by the GNU General Public License.  *Note GPL license::.
  2485.      The text of this license can be found as the file `COPYING' in
  2486.      MySQL distributions.
  2487.  
  2488.   2. The GNU `getopt' library is covered by the GNU Lesser General
  2489.      Public License.  See `http://www.fsf.org/licenses/'.
  2490.  
  2491.   3. Some parts of the source (the `regexp' library) are covered by a
  2492.      Berkeley-style copyright.
  2493.  
  2494.   4. Older versions of MySQL (3.22 and earlier) are subject to a
  2495.      stricter license
  2496.      (`http://www.mysql.com/products/licensing/mypl.html').  See the
  2497.      documentation of the specific version for information.
  2498.  
  2499.   5. The MySQL Reference Manual is _not_ distributed under a GPL-style
  2500.      license. Use of the manual is subject to the following terms:
  2501.         * Conversion to other formats is allowed, but the actual content
  2502.           may not be altered or edited in any way.
  2503.  
  2504.         * You may create a printed copy for your own personal use.
  2505.  
  2506.         * For all other uses, such as selling printed copies or using
  2507.           (parts of) the manual in another publication, prior written
  2508.           agreement from MySQL AB is required.
  2509.      Please send an email message to <docs@mysql.com> for more
  2510.      information or if you are interested in doing a translation.
  2511.  
  2512. For information about how the MySQL licenses work in practice, please
  2513. refer to *Note MySQL licenses:: and *Note MySQL AB Logos and
  2514. Trademarks::.
  2515.  
  2516. MySQL Licenses
  2517. --------------
  2518.  
  2519. The MySQL software is released under the GNU General Public License
  2520. (GPL), which is probably the best known Open Source license.  The
  2521. formal terms of the GPL license can be found at
  2522. `http://www.fsf.org/licenses/'.  See also
  2523. `http://www.fsf.org/licenses/gpl-faq.html' and
  2524. `http://www.gnu.org/philosophy/enforcing-gpl.html'.
  2525.  
  2526. Our GPL licensing is supported by an optional license exception that
  2527. enables many Free/Libre and Open Source Software ("FLOSS") applications
  2528. to include the GPL-licensed MySQL client libraries despite the fact
  2529. that not all FLOSS licenses are compatible with the GPL. For details,
  2530. see `http://www.mysql.com/products/licensing/foss-exception.html'.
  2531.  
  2532. Because the MySQL software is released under the GPL, it may often be
  2533. used for free, but for certain uses you may want or need to buy
  2534. commercial licenses from MySQL AB at `https://order.mysql.com/'.  See
  2535. `http://www.mysql.com/products/licensing/' for more information.
  2536.  
  2537. Older versions of MySQL (3.22 and earlier) are subject to a stricter
  2538. license (`http://www.mysql.com/products/licensing/mypl.html').  See the
  2539. documentation of the specific version for information.
  2540.  
  2541. Please note that the use of the MySQL software under commercial
  2542. license, GPL, or the old MySQL license does not automatically give you
  2543. the right to use MySQL AB (registered) trademarks.  *Note MySQL AB
  2544. Logos and Trademarks::.
  2545.  
  2546. Using the MySQL Software Under a Commercial License
  2547. ...................................................
  2548.  
  2549. The GPL license is contagious in the sense that when a program is
  2550. linked to a GPL program, all the source code for all the parts of the
  2551. resulting product must also be released under the GPL.  If you do not
  2552. follow this GPL requirement, you break the license terms and forfeit
  2553. your right to use the GPL program altogether.  You also risk damages.
  2554.  
  2555. You need a commercial license under these conditions:
  2556.  
  2557.    * When you link a program with any GPL code from the MySQL software
  2558.      and don't want the resulting product to be licensed under GPL,
  2559.      perhaps because you want to build a commercial product or keep the
  2560.      added non-GPL code closed source for other reasons. When purchasing
  2561.      commercial licenses, you are not using the MySQL software under
  2562.      GPL even though it's the same code.
  2563.  
  2564.    * When you distribute a non-GPL application that works _only_ with
  2565.      the MySQL software and ship it with the MySQL software. This type
  2566.      of solution is considered to be linking even if it's done over a
  2567.      network.
  2568.  
  2569.    * When you distribute copies of the MySQL software without providing
  2570.      the source code as required under the GPL license.
  2571.  
  2572.    * When you want to support the further development of the MySQL
  2573.      database even if you don't formally need a commercial license.
  2574.      Purchasing support directly from MySQL AB is another good way of
  2575.      contributing to the development of the MySQL software, with
  2576.      immediate advantages for you.  *Note Support::.
  2577.  
  2578. Our GPL licensing is supported by an optional license exception that
  2579. enables many Free/Libre and Open Source Software ("FLOSS") applications
  2580. to include the GPL-licensed MySQL client libraries despite the fact
  2581. that not all FLOSS licenses are compatible with the GPL. For details,
  2582. see `http://www.mysql.com/products/licensing/foss-exception.html'.
  2583.  
  2584. If you require a commercial license, you will need one for each
  2585. installation of the MySQL software. This covers any number of CPUs on a
  2586. machine, and there is no artificial limit on the number of clients that
  2587. connect to the server in any way.
  2588.  
  2589. For commercial licenses, please visit our Web site at
  2590. `http://www.mysql.com/products/licensing/'.  For support contracts, see
  2591. `http://www.mysql.com/support/'.  If you have special needs, please
  2592. contact our sales staff via email at <sales@mysql.com>.
  2593.  
  2594. Using the MySQL Software for Free Under GPL
  2595. ...........................................
  2596.  
  2597. You can use the MySQL software for free under the GPL if you adhere to
  2598. the conditions of the GPL.  For additional details about the GPL,
  2599. including answers to common questions, see the generic FAQ from the
  2600. Free Software Foundation at `http://www.fsf.org/licenses/gpl-faq.html'.
  2601.  
  2602. Our GPL licensing is supported by an optional license exception that
  2603. enables many Free/Libre and Open Source Software ("FLOSS") applications
  2604. to include the GPL-licensed MySQL client libraries despite the fact
  2605. that not all FLOSS licenses are compatible with the GPL. For details,
  2606. see `http://www.mysql.com/products/licensing/foss-exception.html'.
  2607.  
  2608. Common uses of the GPL include:
  2609.  
  2610.    * When you distribute both your own application and the MySQL source
  2611.      code under the GPL with your product.
  2612.  
  2613.    * When you distribute the MySQL source code bundled with other
  2614.      programs that are not linked to or dependent on the MySQL system
  2615.      for their functionality even if you sell the distribution
  2616.      commercially.  This is called "mere aggregation" in the GPL
  2617.      license.
  2618.  
  2619.    * When you are not distributing _any_ part of the MySQL system, you
  2620.      can use it for free.
  2621.  
  2622.    * When you are an Internet Service Provider (ISP), offering Web
  2623.      hosting with MySQL servers for your customers.  We encourage
  2624.      people to use ISPs that have MySQL support, because doing so will
  2625.      give them the confidence that their ISP will, in fact, have the
  2626.      resources to solve any problems they may experience with the MySQL
  2627.      installation. Even if an ISP does not have a commercial license
  2628.      for MySQL Server, their customers should at least be given read
  2629.      access to the source of the MySQL installation so that the
  2630.      customers can verify that it is correctly patched.
  2631.  
  2632.    * When you use the MySQL database software in conjunction with a Web
  2633.      server, you do not need a commercial license (so long as it is not
  2634.      a product you distribute). This is true even if you run a
  2635.      commercial Web server that uses MySQL Server, because you are not
  2636.      distributing any part of the MySQL system. However, in this case
  2637.      we would like you to purchase MySQL support because the MySQL
  2638.      software is helping your enterprise.
  2639.  
  2640. If your use of MySQL database software does not require a commercial
  2641. license, we encourage you to purchase support from MySQL AB anyway.
  2642. This way you contribute toward MySQL development and also gain
  2643. immediate advantages for yourself. *Note Support::.
  2644.  
  2645. If you use the MySQL database software in a commercial context such
  2646. that you profit by its use, we ask that you further the development of
  2647. the MySQL software by purchasing some level of support.  We feel that
  2648. if the MySQL database helps your business, it is reasonable to ask that
  2649. you help MySQL AB.  (Otherwise, if you ask us support questions, you
  2650. are not only using for free something into which we've put a lot a
  2651. work, you're asking us to provide free support, too.)
  2652.  
  2653. MySQL AB Logos and Trademarks
  2654. -----------------------------
  2655.  
  2656. Many users of the MySQL database want to display the MySQL AB dolphin
  2657. logo on their Web sites, books, or boxed products. We welcome and
  2658. encourage this, although it should be noted that the word MySQL and the
  2659. MySQL dolphin logo are (registered) trademarks of MySQL AB and may only
  2660. be used as stated in our trademark policy at
  2661. `http://www.mysql.com/company/trademark.html'.
  2662.  
  2663. The Original MySQL Logo
  2664. .......................
  2665.  
  2666. The MySQL dolphin logo was designed by the Finnish advertising agency
  2667. Priority in 2001.  The dolphin was chosen as a suitable symbol for the
  2668. MySQL database management system, which is like a smart, fast, and lean
  2669. animal, effortlessly navigating oceans of data. We also happen to like
  2670. dolphins.
  2671.  
  2672. The original MySQL logo may only be used by representatives of MySQL AB
  2673. and by those having a written agreement allowing them to do so.
  2674.  
  2675. MySQL Logos That May Be Used Without Written Permission
  2676. .......................................................
  2677.  
  2678. We have designed a set of special _Conditional Use_ logos that may be
  2679. downloaded from our Web site at `http://www.mysql.com/press/logos.html'
  2680. and used on third-party Web sites without written permission from MySQL
  2681. AB.  The use of these logos is not entirely unrestricted but, as the
  2682. name implies, subject to our trademark policy that is also available on
  2683. our Web site. You should read through the trademark policy if you plan
  2684. to use them. The requirements are basically as follows:
  2685.  
  2686.    * Use the logo you need as displayed on the `http://www.mysql.com/'
  2687.      site. You may scale it to fit your needs, but may not change
  2688.      colors or design, or alter the graphics in any way.
  2689.  
  2690.    * Make it evident that you, and not MySQL AB, are the creator and
  2691.      owner of the site that displays the MySQL (registered) trademark.
  2692.  
  2693.    * Don't use the trademark in a way that is detrimental to MySQL AB
  2694.      or to the value of MySQL AB trademarks. We reserve the right to
  2695.      revoke the right to use the MySQL AB trademark.
  2696.  
  2697.    * If you use the trademark on a Web site, make it clickable, leading
  2698.      directly to `http://www.mysql.com/'.
  2699.  
  2700.    * If you use the MySQL database under GPL in an application, your
  2701.      application must be Open Source and must be able to connect to a
  2702.      MySQL server.
  2703.  
  2704. Contact us via email at <trademark@mysql.com> to inquire about special
  2705. arrangements to fit your needs.
  2706.  
  2707. When You Need Written Permission to Use MySQL Logos
  2708. ...................................................
  2709.  
  2710. You need written permission from MySQL AB before using MySQL logos in
  2711. the following cases:
  2712.  
  2713.    * When displaying any MySQL AB logo anywhere except on your Web site.
  2714.  
  2715.    * When displaying any MySQL AB logo except the _Conditional Use_
  2716.      logos (mentioned previously) on Web sites or elsewhere.
  2717.  
  2718. Due to legal and commercial reasons, we monitor the use of MySQL
  2719. (registered) trademarks on products, books, and other items.  We
  2720. usually require a fee for displaying MySQL AB logos on commercial
  2721. products, since we think it is reasonable that some of the revenue is
  2722. returned to fund further development of the MySQL database.
  2723.  
  2724. MySQL AB Partnership Logos
  2725. ..........................
  2726.  
  2727. MySQL partnership logos may be used only by companies and persons
  2728. having a written partnership agreement with MySQL AB. Partnerships
  2729. include certification as a MySQL trainer or consultant.  For more
  2730. information, please see *Note Partnering: Business Services Partnering.
  2731.  
  2732. Using the Word MySQL in Printed Text or Presentations
  2733. .....................................................
  2734.  
  2735. MySQL AB welcomes references to the MySQL database, but it should be
  2736. noted that the word MySQL is a registered trademark of MySQL AB.
  2737. Because of this, you must append the "registered trademark" notice
  2738. symbol (`R') to the first or most prominent use of the word MySQL in a
  2739. text and, where appropriate, state that MySQL is a registered trademark
  2740. of MySQL AB. For more information, please refer to our trademark policy
  2741. at `http://www.mysql.com/company/trademark.html'.
  2742.  
  2743. Using the Word MySQL in Company and Product Names
  2744. .................................................
  2745.  
  2746. Use of the word MySQL in company or product names or in Internet domain
  2747. names is not allowed without written permission from MySQL AB.
  2748. `http://www.mysql.com/company/contact/'.
  2749.  
  2750. MySQL Development Roadmap
  2751. =========================
  2752.  
  2753. This section provides a snapshot of the MySQL development roadmap,
  2754. including major features implemented or planned for MySQL 4.0, 4.1,
  2755. 5.0, and 5.1.  The following sections provide information for each
  2756. release series.
  2757.  
  2758. The production release series is MySQL 4.0, which was declared stable
  2759. for production use as of Version 4.0.12, released in March 2003. This
  2760. means that future 4.0 development is limited only to bugfixes.  For the
  2761. older MySQL 3.23 series, only critical bugfixes are made.
  2762.  
  2763. 4.1 is available in gamma status and will soon move to production stage.
  2764.  
  2765. Active MySQL development currently is taking place in the MySQL 5.0
  2766. release series, this means that new features are being added there.
  2767. MySQL 5.0 is available in alpha status.
  2768.  
  2769. Before upgrading from one release series to the next, please see the
  2770. notes at *Note Upgrade::.
  2771.  
  2772. Plans for some of the most requested features are summarized in the
  2773. following table.
  2774.  
  2775. *Feature*              *MySQL Series*
  2776. Unions                 4.0
  2777. Subqueries             4.1
  2778. R-trees                4.1 (for `MyISAM' tables)
  2779. Stored procedures      5.0
  2780. Views                  5.0
  2781. Cursors                5.0
  2782. Foreign keys           5.1 (already implemented in 3.23 for
  2783.                        `InnoDB')
  2784. Triggers               5.0 and 5.1
  2785. Full outer join        5.1
  2786. Constraints            5.1
  2787.  
  2788. MySQL 4.0 in a Nutshell
  2789. -----------------------
  2790.  
  2791. MySQL Server 4.0 is available in production status.
  2792.  
  2793. MySQL 4.0 is available for download at `http://dev.mysql.com/' and from
  2794. our mirrors. MySQL 4.0 has been tested by a large number of users and
  2795. is in production use at many large sites.
  2796.  
  2797. The major new features of MySQL Server 4.0 are geared toward our
  2798. existing business and community users, enhancing the MySQL database
  2799. software as the solution for mission-critical, heavy-load database
  2800. systems.  Other new features target the users of embedded databases.
  2801.  
  2802. Features Available in MySQL 4.0
  2803. ...............................
  2804.  
  2805. Speed enhancements
  2806.         * MySQL 4.0 has a query cache that can give a huge speed boost
  2807.           to applications with repetitive queries. *Note Query Cache::.
  2808.  
  2809.         * Version 4.0 further increases the speed of MySQL Server in a
  2810.           number of areas, such as bulk `INSERT' statements, searching
  2811.           on packed indexes, full-text searching (using `FULLTEXT'
  2812.           indexes), and `COUNT(DISTINCT)'.
  2813.  
  2814. Embedded MySQL Server introduced
  2815.         * The new Embedded Server library can easily be used to create
  2816.           standalone and embedded applications.  The embedded server
  2817.           provides an alternative to using MySQL in a client/server
  2818.           environment.  *Note Nutshell Embedded MySQL::.
  2819.  
  2820. `InnoDB' storage engine as standard
  2821.         * The `InnoDB' storage engine is offered as a standard feature
  2822.           of the MySQL server. This means full support for ACID
  2823.           transactions, foreign keys with cascading `UPDATE' and
  2824.           `DELETE', and row-level locking are now standard features.
  2825.           *Note `InnoDB': InnoDB.
  2826.  
  2827. New functionality
  2828.         * The enhanced `FULLTEXT' search properties of MySQL Server 4.0
  2829.           enables `FULLTEXT' indexing of large text masses with both
  2830.           binary and natural-language searching logic. You can
  2831.           customize minimal word length and define your own stop word
  2832.           lists in any human language, enabling a new set of
  2833.           applications to be built with MySQL Server.  *Note Fulltext
  2834.           Search::.
  2835.  
  2836. Standards compliance, portability, and migration
  2837.         * Many users will also be happy to learn that MySQL Server now
  2838.           supports the `UNION' statement, a long-awaited standard SQL
  2839.           feature.
  2840.  
  2841.         * MySQL runs natively on the Novell NetWare platform beginning
  2842.           with NetWare 6.0.  *Note NetWare installation::.
  2843.  
  2844.         * Features to simplify migration from other database systems to
  2845.           MySQL Server include `TRUNCATE TABLE' (as in Oracle).
  2846.  
  2847. Internationalization
  2848.         * Our German, Austrian, and Swiss users will note that MySQL
  2849.           4.0 now supports a new character set, `latin1_de', which
  2850.           ensures that the _German sorting order_ sorts words with
  2851.           umlauts in the same order as do German telephone books.
  2852.  
  2853. Usability enhancements
  2854.      In the process of implementing features for new users, we have not
  2855.      forgotten requests from our loyal community of existing users.
  2856.  
  2857.         * Most `mysqld' parameters (startup options) can be set without
  2858.           taking down the server. This is a convenient feature for
  2859.           database administrators (DBAs).  *Note `SET OPTION': SET
  2860.           OPTION.
  2861.  
  2862.         * Multiple-table `DELETE' and `UPDATE' statements have been
  2863.           added.
  2864.  
  2865.         * On Windows, symbolic link handling at the database level is
  2866.           enabled by default.  On Unix, the `MyISAM' storage engine
  2867.           supports symbolic linking at the table level (and not just
  2868.           the database level as before).
  2869.  
  2870.         * `SQL_CALC_FOUND_ROWS' and `FOUND_ROWS()' are new functions
  2871.           that make it possible to find out the number of rows a
  2872.           `SELECT' query that includes a `LIMIT' clause would have
  2873.           returned without that clause.
  2874.  
  2875. The news section of this manual includes a more in-depth list of
  2876. features.  *Note News-4.0.x::.
  2877.  
  2878. The Embedded MySQL Server
  2879. .........................
  2880.  
  2881. The `libmysqld' embedded server library makes MySQL Server suitable for
  2882. a vastly expanded realm of applications. By using this library,
  2883. developers can embed MySQL Server into various applications and
  2884. electronics devices, where the end user has no knowledge of there
  2885. actually being an underlying database. Embedded MySQL Server is ideal
  2886. for use behind the scenes in Internet appliances, public kiosks, turnkey
  2887. hardware/software combination units, high performance Internet servers,
  2888. self-contained databases distributed on CD-ROM, and so on.
  2889.  
  2890. Many users of `libmysqld' will benefit from the MySQL Dual Licensing.
  2891. For those not wishing to be bound by the GPL, the software is also made
  2892. available under a commercial license.  The embedded MySQL library uses
  2893. the same interface as the normal client library, so it is convenient
  2894. and easy to use.  *Note `libmysqld': libmysqld.
  2895.  
  2896. On windows there are two different libraries:
  2897.  
  2898. `libmysqld.lib'        Dynamic library for threaded applications.
  2899. `mysqldemb.lib'        Static library for not threaded
  2900.                        applications.
  2901.  
  2902. MySQL 4.1 in a Nutshell
  2903. -----------------------
  2904.  
  2905. MySQL Server 4.0 laid the foundation for new features implemented in
  2906. MySQL 4.1, such as subqueries and Unicode support, and for the work on
  2907. stored procedures being done in version 5.0.  These features come at
  2908. the top of the wish list of many of our customers.  Already well-known
  2909. for its stability, speed, and ease of use, MySQL Server is now able to
  2910. fulfill the requirement checklists of very demanding buyers.
  2911.  
  2912. MySQL 4.1 is now available in gamma status, and will be production soon.
  2913.  
  2914. Features Available in MySQL 4.1
  2915. ...............................
  2916.  
  2917. This section lists features implemented in MySQL 4.1.
  2918.  
  2919. New features currently being coded are or will be available in MySQL
  2920. 5.0.  *Note TODO MySQL 5.0::.
  2921.  
  2922. Support for subqueries and derived tables
  2923.         * A "subquery" is a `SELECT' statement nested within another
  2924.           statement.  A "derived table" (an unnamed view) is a subquery
  2925.           in the `FROM' clause of another statement.  *Note
  2926.           Subqueries::.
  2927.  
  2928. Speed enhancements
  2929.         * Faster binary client/server protocol with support for
  2930.           prepared statements and parameter binding.  *Note C API
  2931.           Prepared statements::.
  2932.  
  2933.         * `BTREE' indexing is supported for `HEAP' tables,
  2934.           significantly improving response time for non-exact searches.
  2935.  
  2936. New functionality
  2937.         * `CREATE TABLE TBL_NAME2 LIKE TBL_NAME1' allows you to create,
  2938.           with a single statement, a new table with a structure exactly
  2939.           like that of an existing table.
  2940.  
  2941.         * The `MyISAM' storage engine supports OpenGIS spatial types
  2942.           for storing geographical data.  *Note Spatial extensions in
  2943.           MySQL::.
  2944.  
  2945.         * Replication can be done over SSL connections.
  2946.  
  2947. Standards compliance, portability, and migration
  2948.         * The new client/server protocol adds the ability to pass
  2949.           multiple warnings to the client, rather than only a single
  2950.           result. This makes it much easier to track problems that
  2951.           occur in operations such as bulk data loading.
  2952.  
  2953.         * `SHOW WARNINGS' shows warnings for the last command.  *Note
  2954.           `SHOW WARNINGS': SHOW WARNINGS.
  2955.  
  2956. Internationalization and Localization
  2957.         * To support applications that require the use of local
  2958.           languages, the MySQL software offers extensive Unicode
  2959.           support through the `utf8' and `ucs2' character sets.
  2960.  
  2961.         * Character sets can be defined per column, table, and database.
  2962.           This allows for a high degree of flexibility in application
  2963.           design, particularly for multi-language Web sites.
  2964.  
  2965.         * For documentation for this improved character set support,
  2966.           see *Note Charset::.
  2967.  
  2968.         * Per-connection time zones are supported, allowing individual
  2969.           clients to select their own time zone when necessary.
  2970.  
  2971. Usability enhancements
  2972.         * In response to popular demand, we have added a server-based
  2973.           `HELP' command that can be used to get help information for
  2974.           SQL statements.  The advantage of having this information on
  2975.           the server side is that the information is always applicable
  2976.           to the particular server version that you actually are using.
  2977.           Because this information is available by issuing an SQL
  2978.           statement, any client can be written to access it.  For
  2979.           example, the `help' command of the `mysql' command-line client
  2980.           has been modified to have this capability.
  2981.  
  2982.         * In the new client/server protocol, multiple statements can be
  2983.           issued with a single call.  *Note C API multiple queries::.
  2984.  
  2985.         * The new client/server protocol also supports returning
  2986.           multiple result sets.  This might occur as a result of
  2987.           sending multiple statements, for example.
  2988.  
  2989.         * A new `INSERT ... ON DUPLICATE KEY UPDATE ...' syntax has been
  2990.           implemented. This allows you to `UPDATE' an existing row if
  2991.           the `INSERT' would have caused a duplicate in a `PRIMARY' or
  2992.           `UNIQUE' index.  *Note `INSERT': INSERT.
  2993.  
  2994.         * A new aggregate function, `GROUP_CONCAT()' adds the extremely
  2995.           useful capability of concatenating column values from grouped
  2996.           rows into a single result string.  *Note Group by functions
  2997.           and modifiers::.
  2998.  
  2999. The news section of this manual includes a more in-depth list of
  3000. features.  *Note News-4.1.x::.
  3001.  
  3002. Stepwise Rollout
  3003. ................
  3004.  
  3005. The gamma version of MySQL 4.1 is available for download.  *Note
  3006. Nutshell Ready for Immediate Use::.
  3007.  
  3008. MySQL 4.1 is currently in the _Gamma_ stage (indicating that a
  3009. production release is just weeks ahead).  At the end of this process,
  3010. MySQL 4.1 will become the new production release.
  3011.  
  3012. Development is already ongoing for version 5.0.
  3013.  
  3014. Ready for Immediate Development Use
  3015. ...................................
  3016.  
  3017. MySQL 4.1 is currently in the gamma stage, and binaries are available
  3018. for download at `http://dev.mysql.com/downloads/mysql/4.1.html'.  All
  3019. binary releases pass our extensive test suite without any errors on the
  3020. platforms on which we test.  *Note News-4.1.x::.
  3021.  
  3022. For those wishing to use the most recent development source for MySQL
  3023. 4.1, we also make our BitKeeper repositories publicly available.  *Note
  3024. Installing source tree::.
  3025.  
  3026. MySQL 5.0: The Next Development Release
  3027. ---------------------------------------
  3028.  
  3029. New development for MySQL is focused on the 5.0 release, featuring
  3030. stored procedures, updatable views, rudimentary triggers, and other new
  3031. features.  *Note TODO MySQL 5.0::.
  3032.  
  3033. For those wishing to take a look at the bleeding edge of MySQL
  3034. development, we make our BitKeeper repository for MySQL version 5.0
  3035. publicly available.  *Note Installing source tree::.  As of December
  3036. 2003, binary builds of version 5.0 have also been available.
  3037.  
  3038. MySQL and the Future (the TODO)
  3039. ===============================
  3040.  
  3041. This section summarizes the features that we plan to implement in MySQL
  3042. Server. The items are ordered by release series. Within a list, items
  3043. are shown in approximately the order they will be done.
  3044.  
  3045. *Note*: If you are an enterprise-level user with an urgent need for a
  3046. particular feature, please contact <sales@mysql.com> to discuss
  3047. sponsoring options. Targeted financing by sponsor companies allows us
  3048. to allocate additional resources for specific purposes.  One example of
  3049. a feature sponsored in the past is replication.
  3050.  
  3051. New Features Planned for 5.0
  3052. ----------------------------
  3053.  
  3054. The following features are planned for inclusion into MySQL 5.0.  Some
  3055. of the features such as stored procedures are complete and are included
  3056. in MySQL 5.0 alpha, which is available now.  Others such as cursors are
  3057. only partially available. Expect these and other features to mature and
  3058. be fully supported in upcoming releases.
  3059.  
  3060. Note that because we have many developers that are working on different
  3061. projects, there will also be many additional features. There is also a
  3062. small chance that some of these features will be added to MySQL 4.1.
  3063. For a list what is already done in MySQL 4.1, see *Note Nutshell 4.1
  3064. features::.
  3065.  
  3066. For those wishing to take a look at the bleeding edge of MySQL
  3067. development, we make our BitKeeper repository for MySQL version 5.0
  3068. publicly available.  *Note Installing source tree::.  As of December
  3069. 2003, binary builds of version 5.0 are also available.
  3070.  
  3071. Views
  3072.         * Views, implemented in stepwise fashion up to full
  3073.           functionality.  *Note ANSI diff Views::. *Note CREATE VIEW::.
  3074.  
  3075. Stored Procedures
  3076.         * Stored procedures currently are implemented, based on the
  3077.           SQL:2003 standard.  *Note Stored Procedures::.
  3078.  
  3079.  
  3080. New functionality
  3081.         * Elementary cursor support.  *Note Cursors::.
  3082.  
  3083.         * The ability to specify explicitly for `MyISAM' tables that an
  3084.           index should be created as an `RTREE' index.  (In MySQL 4.1,
  3085.           `RTREE' indexes are used internally for geometrical data that
  3086.           use GIS data types, but cannot be created on request.)
  3087.  
  3088.         * Dynamic length rows for `MEMORY' tables.
  3089.  
  3090. Standards compliance, portability and migration
  3091.         * Support for Data Dictionary / `INFORMATION_SCHEMA'.
  3092.  
  3093.         * Add true `VARCHAR' support (column lengths longer than 255,
  3094.           and no stripping of trailing whitespace).  There is already
  3095.           support for this in the `MyISAM' storage engine, but it is
  3096.           not yet available at the user level.
  3097.  
  3098. Speed enhancements
  3099.         * `SHOW COLUMNS FROM TBL_NAME' (used by the `mysql' client to
  3100.           allow expansions of column names) should not open the table,
  3101.           only the definition file. This will require less memory and
  3102.           be much faster.
  3103.  
  3104.         * Allow `DELETE' on `MyISAM' tables to use the record cache.
  3105.           To do this, we need to update the threads record cache when
  3106.           we update the `.MYD' file.
  3107.  
  3108.         * Better support for `MEMORY' tables:
  3109.              * Dynamic length rows.
  3110.  
  3111.              * Faster row handling (less copying).
  3112.  
  3113. Usability enhancements
  3114.         * Resolving the issue of `RENAME TABLE' on a table used in an
  3115.           active `MERGE' table possibly corrupting the table.
  3116.  
  3117. The news section of this manual includes a more in-depth list of
  3118. features.  *Note News-5.0.x::.
  3119.  
  3120. New Features Planned for 5.1
  3121. ----------------------------
  3122.  
  3123. New functionality
  3124.         * `FOREIGN KEY' support for all table types, not just `InnoDB'.
  3125.  
  3126.         * Column-level constraints.  *Note Constraints::.
  3127.  
  3128.         * Online backup with very low performance penalty.  The online
  3129.           backup will make it easy to add a new replication slave
  3130.           without taking down the master.
  3131.  
  3132. Speed enhancements
  3133.         * New text based table definition file format (`.frm' files)
  3134.           and a table cache for table definitions.  This will enable us
  3135.           to do faster queries of table structures and do more
  3136.           efficient foreign key support.
  3137.  
  3138.         * Optimize the `BIT' type to take one bit. (`BIT' now takes one
  3139.           byte; it is treated as a synonym for `TINYINT'.)
  3140.  
  3141. Usability enhancements
  3142.         * Add options to the client/server protocol to get progress
  3143.           notes for long running commands.
  3144.  
  3145.         * Implement `RENAME DATABASE'. To make this safe for all
  3146.           storage engines, it should work as follows:
  3147.             1. Create the new database.
  3148.  
  3149.             2. For every table, do a rename of the table to another
  3150.                database, as we do with the `RENAME' command.
  3151.  
  3152.             3. Drop the old database.
  3153.  
  3154.         * New internal file interface change.  This will make all file
  3155.           handling much more general and make it easier to add
  3156.           extensions like RAID.
  3157.  
  3158. New Features Planned for the Near Future
  3159. ----------------------------------------
  3160.  
  3161. New functionality
  3162.         * Oracle-like `CONNECT BY PRIOR' to search tree-like
  3163.           (hierarchical) structures.
  3164.  
  3165.         * Add all missing standard SQL and ODBC 3.0 types.
  3166.  
  3167.         * Add `SUM(DISTINCT)'.
  3168.  
  3169.         * `INSERT SQL_CONCURRENT' and `mysqld --concurrent-insert' to do
  3170.           a concurrent insert at the end of a table if the table is
  3171.           read-locked.
  3172.  
  3173.         * Allow variables to be updated in `UPDATE' statements. For
  3174.           example: `UPDATE foo SET @a:=a+b,a=@a, b=@a+c'.
  3175.  
  3176.         * Change when user variables are updated so that you can use
  3177.           them with `GROUP BY', as in the following statement: `SELECT
  3178.           id, @a:=COUNT(*), SUM(SUM_COL)/@a FROM TBL_NAME GROUP BY id'.
  3179.  
  3180.         * Add an `IMAGE' option to `LOAD DATA INFILE' to not update
  3181.           `TIMESTAMP' and `AUTO_INCREMENT' columns.
  3182.  
  3183.         * Add `LOAD DATA INFILE ... UPDATE' syntax that works like this:
  3184.              * For tables with primary keys, if an input record
  3185.                contains a primary key value, existing rows matching
  3186.                that primary key value are updated from the remainder of
  3187.                the input columns. However, columns corresponding to
  3188.                columns that are _missing_ from the input record are not
  3189.                touched.
  3190.  
  3191.              * For tables with primary keys, if an input record does
  3192.                not contain the primary key value or is missing some
  3193.                part of the key, the record is treated as `LOAD DATA
  3194.                INFILE ... REPLACE INTO'.
  3195.  
  3196.         * Make `LOAD DATA INFILE' understand syntax like this:
  3197.                LOAD DATA INFILE 'FILE_NAME.txt' INTO TABLE TBL_NAME
  3198.                     TEXT_FIELDS (text_col1, text_col2, text_col3)
  3199.                     SET table_col1=CONCAT(text_col1, text_col2),
  3200.                         table_col3=23
  3201.                     IGNORE text_col3
  3202.           This can be used to skip over extra columns in the text file,
  3203.           or update columns based on expressions of the read data.
  3204.  
  3205.         * New functions for working with `SET' type columns:
  3206.              * `ADD_TO_SET(VALUE,SET)'
  3207.  
  3208.              * `REMOVE_FROM_SET(VALUE,SET)'
  3209.  
  3210.         * If you abort `mysql' in the middle of a query, you should open
  3211.           another connection and kill the old running query.
  3212.           Alternatively, an attempt should be made to detect this in
  3213.           the server.
  3214.  
  3215.         * Add a storage engine interface for table information so that
  3216.           you can use it as a system table. This would be a bit slow if
  3217.           you requested information about all tables, but very
  3218.           flexible.  `SHOW INFO FROM TBL_NAME' for basic table
  3219.           information should be implemented.
  3220.  
  3221.         * Allow `SELECT a FROM TBL_NAME1 LEFT JOIN TBL_NAME2 USING
  3222.           (a)'; in this case `a' is assumed to come from TBL_NAME1.
  3223.  
  3224.         * `DELETE' and `REPLACE' options to the `UPDATE' statement
  3225.           (this will delete rows when a duplicate-key error occurs
  3226.           while updating).
  3227.  
  3228.         * Change the format of `DATETIME' to store fractions of seconds.
  3229.  
  3230.         * Make it possible to use the new GNU `regexp' library instead
  3231.           of the current one (the new library should be much faster
  3232.           than the current one).
  3233.  
  3234. Standards compliance, portability and migration
  3235.         * Add `ANY()', `EVERY()', and `SOME()' group functions. In
  3236.           standard SQL, these work only on boolean columns, but we can
  3237.           extend these to work on any columns or expressions by
  3238.           treating a value of zero as FALSE and non-zero values as TRUE.
  3239.  
  3240.         * Fix the type of `MAX(column)' to be the same as the column
  3241.           type:
  3242.                mysql> CREATE TABLE t1 (a DATE);
  3243.                mysql> INSERT INTO t1 VALUES (NOW());
  3244.                mysql> CREATE TABLE t2 SELECT MAX(a) FROM t1;
  3245.                mysql> SHOW COLUMNS FROM t2;
  3246.  
  3247. Speed enhancements
  3248.         * Don't allow more than a defined number of threads to run
  3249.           `MyISAM' recovery at the same time.
  3250.  
  3251.         * Change `INSERT INTO ... SELECT' to optionally use concurrent
  3252.           inserts.
  3253.  
  3254.         * Add an option to periodically flush key pages for tables with
  3255.           delayed keys if they haven't been used in a while.
  3256.  
  3257.         * Allow join on key parts (optimization issue).
  3258.  
  3259.         * Add a log file analyzer that can extract information about
  3260.           which tables are hit most often, how often multiple-table
  3261.           joins are executed, and so on. This should help users
  3262.           identify areas of table design that could be optimized to
  3263.           execute much more efficient queries.
  3264.  
  3265. Usability enhancements
  3266.         * Return the original column types when doing `SELECT
  3267.           MIN(column) ... GROUP BY'.
  3268.  
  3269.         * Make it possible to specify `long_query_time' with a
  3270.           granularity in microseconds.
  3271.  
  3272.         * Link the `myisampack' code into the server so that it can
  3273.           perform `PACK' or `COMPRESS' operations.
  3274.  
  3275.         * Add a temporary key buffer cache during
  3276.           `INSERT/DELETE/UPDATE' so that we can gracefully recover if
  3277.           the index file gets full.
  3278.  
  3279.         * If you perform an `ALTER TABLE' on a table that is symlinked
  3280.           to another disk, create temporary tables on that disk.
  3281.  
  3282.         * Implement a `DATE/DATETIME' type that handles time zone
  3283.           information properly, to make dealing with dates in different
  3284.           time zones easier.
  3285.  
  3286.         * Fix `configure' so that all libraries (like `MyISAM') can be
  3287.           compiled without threads.
  3288.  
  3289.         * Allow user variables as `LIMIT' arguments; for example,
  3290.           `LIMIT @a,@b'.
  3291.  
  3292.         * Automatic output from `mysql' to a Web browser.
  3293.  
  3294.         * `LOCK DATABASES' (with various options).
  3295.  
  3296.         * Many more variables for `SHOW STATUS'.  Record reads and
  3297.           updates.  Selects on a single table and selects with joins.
  3298.           Mean number of tables in selects. Number of `ORDER BY' and
  3299.           `GROUP BY' queries.
  3300.  
  3301.         * `mysqladmin copy database new-database'; this requires a
  3302.           `COPY' operation to be added to `mysqld'.
  3303.  
  3304.         * Processlist output should indicate the number of
  3305.           queries/threads.
  3306.  
  3307.         * `SHOW HOSTS' for printing information about the hostname
  3308.           cache.
  3309.  
  3310.         * Change table names from empty strings to `NULL' for
  3311.           calculated columns.
  3312.  
  3313.         * Don't use `Item_copy_string' on numerical values to avoid
  3314.           number-to-string-to-number conversion in case of `SELECT
  3315.           COUNT(*)*(id+0) FROM TBL_NAME GROUP BY id'.
  3316.  
  3317.         * Change so that `ALTER TABLE' doesn't abort clients that
  3318.           execute `INSERT DELAYED'.
  3319.  
  3320.         * Fix so that when columns are referenced in an `UPDATE' clause,
  3321.           they contain the old values from before the update started.
  3322.  
  3323. New operating systems
  3324.         * Port the MySQL clients to LynxOS.
  3325.  
  3326. New Features Planned for the Mid-Term Future
  3327. --------------------------------------------
  3328.  
  3329.    * Implement function:
  3330.      `get_changed_tables(timeout,table1,table2,...)'.
  3331.  
  3332.    * Change reading through tables to use `mmap()' when possible. Now
  3333.      only compressed tables use `mmap()'.
  3334.  
  3335.    * Make the automatic timestamp code nicer.  Add timestamps to the
  3336.      update log with `SET TIMESTAMP=val;'.
  3337.  
  3338.    * Use read/write mutex in some places to get more speed.
  3339.  
  3340.    * Automatically close some tables if a table, temporary table, or
  3341.      temporary file gets error 23 (too many open files).
  3342.  
  3343.    * Better constant propagation. When an occurrence of COL_NAME=N is
  3344.      found in an expression, for some constant `n', replace other
  3345.      occurrences of COL_NAME within the expression with `n'.
  3346.      Currently, this is done only for some simple cases.
  3347.  
  3348.    * Change all const expressions with calculated expressions if
  3349.      possible.
  3350.  
  3351.    * Optimize KEY = EXPR comparisons. At the moment, only KEY = COLUMN
  3352.      or KEY = CONSTANT comparisons are optimized.
  3353.  
  3354.    * Join some of the copy functions for nicer code.
  3355.  
  3356.    * Change `sql_yacc.yy' to an inline parser to reduce its size and get
  3357.      better error messages.
  3358.  
  3359.    * Change the parser to use only one rule per different number of
  3360.      arguments in function.
  3361.  
  3362.    * Use of full calculation names in the order part (for Access97).
  3363.  
  3364.    * `MINUS', `INTERSECT', and `FULL OUTER JOIN'.  (Currently `UNION'
  3365.      and `LEFT|RIGHT OUTER JOIN' are supported.)
  3366.  
  3367.    * Allow `SQL_OPTION MAX_SELECT_TIME=val', for placing a time limit
  3368.      on a query.
  3369.  
  3370.    * Allow updates to be logged to a database.
  3371.  
  3372.    * Enhance `LIMIT' to allow retrieval of data from the end of a
  3373.      result set.
  3374.  
  3375.    * Alarm around client connect/read/write functions.
  3376.  
  3377.    * Please note the changes to `mysqld_safe': According to FSSTND
  3378.      (which Debian tries to follow), PID files should go into
  3379.      `/var/run/<progname>.pid' and log files into `/var/log'. It would
  3380.      be nice if you could put the "DATADIR" in the first declaration of
  3381.      "pidfile" and "log" so that the placement of these files can be
  3382.      changed with a single statement.
  3383.  
  3384.    * Allow a client to request logging.
  3385.  
  3386.    * Allow the `LOAD DATA INFILE' statement to read files that have
  3387.      been compressed with `gzip'.
  3388.  
  3389.    * Fix sorting and grouping of `BLOB' columns (partly solved now).
  3390.  
  3391.    * Change to use semaphores when counting threads.  One should first
  3392.      implement a semaphore library for MIT-pthreads.
  3393.  
  3394.    * Add full support for `JOIN' with parentheses.
  3395.  
  3396.    * As an alternative to the one-thread-per-connection model, manage a
  3397.      pool of threads to handle queries.
  3398.  
  3399.    * Allow `GET_LOCK()' to obtain more than one lock.  When doing this,
  3400.      it is also necessary to handle the possible deadlocks this change
  3401.      will introduce.
  3402.  
  3403. New Features We Don't Plan to Implement
  3404. ---------------------------------------
  3405.  
  3406. We aim toward full compliance with ANSI/ISO SQL. There are no features
  3407. we plan not to implement.
  3408.  
  3409. MySQL Information Sources
  3410. =========================
  3411.  
  3412. MySQL Mailing Lists
  3413. -------------------
  3414.  
  3415. This section introduces the MySQL mailing lists and provides guidelines
  3416. as to how the lists should be used. When you subscribe to a mailing
  3417. list, you will receive all postings to the list as email messages. You
  3418. can also send your own questions and answers to the list.
  3419.  
  3420. The MySQL Mailing Lists
  3421. .......................
  3422.  
  3423. To subscribe to or unsubscribe from any of the mailing lists described
  3424. in this section, visit `http://lists.mysql.com/'. For most of them, you
  3425. can select the regular version of the list where you get individual
  3426. messages, or a digest version where you get one large message per day.
  3427.  
  3428. Please _do not_ send messages about subscribing or unsubscribing to any
  3429. of the mailing lists, because such messages are distributed
  3430. automatically to thousands of other users.
  3431.  
  3432. Your local site may have many subscribers to a MySQL mailing list.  If
  3433. so, the site may have a local mailing list, so that messages sent from
  3434. `lists.mysql.com' to your site are propagated to the local list.  In
  3435. such cases, please contact your system administrator to be added to or
  3436. dropped from the local MySQL list.
  3437.  
  3438. If you wish to have traffic for a mailing list go to a separate mailbox
  3439. in your mail program, set up a filter based on the message headers.
  3440. You can use either the `List-ID:' or `Delivered-To:' headers to identify
  3441. list messages.
  3442.  
  3443. The MySQL mailing lists are as follows:
  3444.  
  3445. `announce'
  3446.      This list is for announcements of new versions of MySQL and related
  3447.      programs.  This is a low-volume list to which all MySQL users
  3448.      should subscribe.
  3449.  
  3450. `mysql'
  3451.      This is the main list for general MySQL discussion.  Please note
  3452.      that some topics are better discussed on the more-specialized
  3453.      lists.  If you post to the wrong list, you may not get an answer.
  3454.  
  3455. `bugs'
  3456.      This list will be of interest to you if you want to stay informed
  3457.      about issues reported since the last release of MySQL or if you
  3458.      want to be actively involved in the process of bug hunting and
  3459.      fixing.  *Note Bug reports::.
  3460.  
  3461. `internals'
  3462.      This list is for people who work on the MySQL code.  This is also
  3463.      the forum for discussions on MySQL development and for posting
  3464.      patches.
  3465.  
  3466. `mysqldoc'
  3467.      This list is for people who work on the MySQL documentation:
  3468.      people from MySQL AB, translators, and other community members.
  3469.  
  3470. `benchmarks'
  3471.      This list is for anyone interested in performance issues.
  3472.      Discussions concentrate on database performance (not limited to
  3473.      MySQL), but also include broader categories such as performance of
  3474.      the kernel, filesystem, disk system, and so on.
  3475.  
  3476. `packagers'
  3477.      This list is for discussions on packaging and distributing MySQL.
  3478.      This is the forum used by distribution maintainers to exchange
  3479.      ideas on packaging MySQL and on ensuring that MySQL looks and
  3480.      feels as similar as possible on all supported platforms and
  3481.      operating systems.
  3482.  
  3483. `java'
  3484.      This list is for discussions about the MySQL server and Java. It
  3485.      is mostly used to discuss JDBC drivers, including MySQL
  3486.      Connector/J.
  3487.  
  3488. `win32'
  3489.      This list is for all topics concerning the MySQL software on
  3490.      Microsoft operating systems, such as Windows 9x, Me, NT, 2000, and
  3491.      XP.
  3492.  
  3493. `myodbc'
  3494.      This list is for all topics concerning connecting to the MySQL
  3495.      server with ODBC.
  3496.  
  3497. `gui-tools'
  3498.      This list is for all topics concerning MySQL GUI tools, including
  3499.      `MySQL Administrator' and the `MySQL Control Center' graphical
  3500.      client.
  3501.  
  3502. `cluster'
  3503.      This list is for discussion of MySQL Cluster.
  3504.  
  3505. `dotnet'
  3506.      This list is for discussion of the MySQL server and the .NET
  3507.      platform.  Mostly related to the MySQL Connector/Net provider.
  3508.  
  3509. `plusplus'
  3510.      This list is for all topics concerning programming with the C++
  3511.      API for MySQL.
  3512.  
  3513. `perl'
  3514.      This list is for all topics concerning the Perl support for MySQL
  3515.      with `DBD::mysql'.
  3516.  
  3517. If you're unable to get an answer to your questions from a MySQL mailing
  3518. list, one option is to purchase support from MySQL AB. This will put you
  3519. in direct contact with MySQL developers. *Note Support::.
  3520.  
  3521. The following table shows some MySQL mailing lists in languages other
  3522. than English.  These lists are not operated by MySQL AB.
  3523.  
  3524. `<mysql-france-subscribe@yahoogroups.com>'
  3525.      A French mailing list.
  3526.  
  3527. `<list@tinc.net>'
  3528.      A Korean mailing list.  Email `subscribe mysql your@email.address'
  3529.      to this list.
  3530.  
  3531. `<mysql-de-request@lists.4t2.com>'
  3532.      A German mailing list.  Email `subscribe mysql-de
  3533.      your@email.address' to this list.  You can find information about
  3534.      this mailing list at `http://www.4t2.com/mysql/'.
  3535.  
  3536. `<mysql-br-request@listas.linkway.com.br>'
  3537.      A Portuguese mailing list.  Email `subscribe mysql-br
  3538.      your@email.address' to this list.
  3539.  
  3540. `<mysql-alta@elistas.net>'
  3541.      A Spanish mailing list.  Email `subscribe mysql
  3542.      your@email.address' to this list.
  3543.  
  3544. Asking Questions or Reporting Bugs
  3545. ..................................
  3546.  
  3547. Before posting a bug report or question, please do the following:
  3548.  
  3549.    * Start by searching the MySQL online manual at
  3550.      `http://dev.mysql.com/doc/'.  We try to keep the manual up to date
  3551.      by updating it frequently with solutions to newly found problems.
  3552.      The change history (`http://dev.mysql.com/doc/mysql/en/News.html')
  3553.      can be particularly useful since it is quite possible that a newer
  3554.      version already contains a solution to your problem.
  3555.  
  3556.    * Search in the bugs database at `http://bugs.mysql.com/' to see
  3557.      whether the bug has already been reported and fixed.
  3558.  
  3559.    * Search the MySQL mailing list archives at
  3560.      `http://lists.mysql.com/'.
  3561.  
  3562.    * You can also use `http://www.mysql.com/search/' to search all the
  3563.      Web pages (including the manual) that are located at the MySQL AB
  3564.      Web site.
  3565.  
  3566. If you can't find an answer in the manual or the archives, check with
  3567. your local MySQL expert.  If you still can't find an answer to your
  3568. question, please follow the guidelines on sending mail to a MySQL
  3569. mailing list, outlined in the next section, before contacting us.
  3570.  
  3571. How to Report Bugs or Problems
  3572. ..............................
  3573.  
  3574. The normal place to report bugs is `http://bugs.mysql.com/', which is
  3575. the address for our bugs database.  This database is public, and can be
  3576. browsed and searched by anyone.  If you log in to the system, you will
  3577. also be able to enter new reports.
  3578.  
  3579. Writing a good bug report takes patience, but doing it right the first
  3580. time saves time both for us and for yourself.  A good bug report,
  3581. containing a full test case for the bug, makes it very likely that we
  3582. will fix the bug in the next release.  This section will help you write
  3583. your report correctly so that you don't waste your time doing things
  3584. that may not help us much or at all.
  3585.  
  3586. We encourage everyone to use the `mysqlbug' script to generate a bug
  3587. report (or a report about any problem).  `mysqlbug' can be found in the
  3588. `scripts' directory (source distribution) and in the `bin' directory
  3589. under your MySQL installation directory (binary distribution).  If you
  3590. are unable to use `mysqlbug' (for example, if you are running on
  3591. Windows), it is still vital that you include all the necessary
  3592. information noted in this section (most importantly, a description of
  3593. the operating system and the MySQL version).
  3594.  
  3595. The `mysqlbug' script helps you generate a report by determining much
  3596. of the following information automatically, but if something important
  3597. is missing, please include it with your message.  Please read this
  3598. section carefully and make sure that all the information described here
  3599. is included in your report.
  3600.  
  3601. Preferably, you should test the problem using the latest production or
  3602. development version of MySQL Server before posting.  Anyone should be
  3603. able to repeat the bug by just using `mysql test < script_file' on the
  3604. included test case or by running the shell or Perl script that is
  3605. included in the bug report.
  3606.  
  3607. All bugs posted in the bugs database at `http://bugs.mysql.com/' will
  3608. be corrected or documented in the next MySQL release. If only minor
  3609. code changes are needed to correct a problem, we may also post a patch
  3610. that fixes the problem.
  3611.  
  3612. If you have found a sensitive security bug in MySQL, you can send email
  3613. to <security@mysql.com>.
  3614.  
  3615. If you have a repeatable bug report, please report it to the bugs
  3616. database at `http://bugs.mysql.com/'.  Note that even in this case it's
  3617. good to run the `mysqlbug' script first to find information about your
  3618. system.  Any bug that we are able to repeat has a high chance of being
  3619. fixed in the next MySQL release.
  3620.  
  3621. To report other problems, you can use one of the MySQL mailing lists.
  3622.  
  3623. Remember that it is possible for us to respond to a message containing
  3624. too much information, but not to one containing too little.  People
  3625. often omit facts because they think they know the cause of a problem
  3626. and assume that some details don't matter.  A good principle is this:
  3627. If you are in doubt about stating something, state it.  It is faster
  3628. and less troublesome to write a couple more lines in your report than
  3629. to wait longer for the answer if we must ask you to provide information
  3630. that was missing from the initial report.
  3631.  
  3632. The most common errors made in bug reports are (a) not including the
  3633. version number of the MySQL distribution used, and (b) not fully
  3634. describing the platform on which the MySQL server is installed
  3635. (including the platform type and version number).  This is highly
  3636. relevant information, and in 99 cases out of 100, the bug report is
  3637. useless without it.  Very often we get questions like, "Why doesn't
  3638. this work for me?" Then we find that the feature requested wasn't
  3639. implemented in that MySQL version, or that a bug described in a report
  3640. has already been fixed in newer MySQL versions.  Sometimes the error is
  3641. platform-dependent; in such cases, it is next to impossible for us to
  3642. fix anything without knowing the operating system and the version
  3643. number of the platform.
  3644.  
  3645. If you compiled MySQL from source, remember also to provide information
  3646. about your compiler, if it is related to the problem.  Often people
  3647. find bugs in compilers and think the problem is MySQL-related.  Most
  3648. compilers are under development all the time and become better version
  3649. by version.  To determine whether your problem depends on your
  3650. compiler, we need to know what compiler you use.  Note that every
  3651. compiling problem should be regarded as a bug and reported accordingly.
  3652.  
  3653. It is most helpful when a good description of the problem is included
  3654. in the bug report.  That is, give a good example of everything you did
  3655. that led to the problem and describe, in exact detail, the problem
  3656. itself.  The best reports are those that include a full example showing
  3657. how to reproduce the bug or problem.  *Note Reproduceable test case::.
  3658.  
  3659. If a program produces an error message, it is very important to include
  3660. the message in your report.  If we try to search for something from the
  3661. archives using programs, it is better that the error message reported
  3662. exactly matches the one that the program produces.  (Even the
  3663. lettercase should be observed.)  You should never try to reproduce from
  3664. memory what the error message was; instead, copy and paste the entire
  3665. message into your report.
  3666.  
  3667. If you have a problem with Connector/ODBC (MyODBC), please try to
  3668. generate a trace file and send it with your report.  *Note MyODBC bug
  3669. report::.
  3670.  
  3671. Please remember that many of the people who will read your report will
  3672. do so using an 80-column display.  When generating reports or examples
  3673. using the `mysql' command-line tool, you should therefore use the
  3674. `--vertical' option (or the `\G' statement terminator) for output that
  3675. would exceed the available width for such a display (for example, with
  3676. the `EXPLAIN SELECT' statement; see the example later in this section).
  3677.  
  3678. Please include the following information in your report:
  3679.  
  3680.    * The version number of the MySQL distribution you are using (for
  3681.      example, MySQL 4.0.12). You can find out which version you are
  3682.      running by executing `mysqladmin version'.  The `mysqladmin'
  3683.      program can be found in the `bin' directory under your MySQL
  3684.      installation directory.
  3685.  
  3686.    * The manufacturer and model of the machine on which you experience
  3687.      the problem.
  3688.  
  3689.    * The operating system name and version.  If you work with Windows,
  3690.      you can usually get the name and version number by double-clicking
  3691.      your My Computer icon and pulling down the "Help/About Windows"
  3692.      menu.  For most Unix-like operating systems, you can get this
  3693.      information by executing the command `uname -a'.
  3694.  
  3695.    * Sometimes the amount of memory (real and virtual) is relevant. If
  3696.      in doubt, include these values.
  3697.  
  3698.    * If you are using a source distribution of the MySQL software, the
  3699.      name and version number of the compiler used are needed.  If you
  3700.      have a binary distribution, the distribution name is needed.
  3701.  
  3702.    * If the problem occurs during compilation, include the exact error
  3703.      messages and also a few lines of context around the offending code
  3704.      in the file where the error occurs.
  3705.  
  3706.    * If `mysqld' died, you should also report the query that crashed
  3707.      `mysqld'.  You can usually find this out by running `mysqld' with
  3708.      query logging enabled, and then looking in the log after `mysqld'
  3709.      crashes *Note Using log files::.
  3710.  
  3711.    * If a database table is related to the problem, include the output
  3712.      from `mysqldump --no-data DB_NAME TBL_NAME'.  This is very easy to
  3713.      do and is a powerful way to get information about any table in a
  3714.      database.  The information will help us create a situation
  3715.      matching the one you have.
  3716.  
  3717.    * For speed-related bugs or problems with `SELECT' statements, you
  3718.      should always include the output of `EXPLAIN SELECT ...', and at
  3719.      least the number of rows that the `SELECT' statement produces.  You
  3720.      should also include the output from `SHOW CREATE TABLE TBL_NAME'
  3721.      for each involved table. The more information you give about your
  3722.      situation, the more likely it is that someone can help you.
  3723.  
  3724.      The following is an example of a very good bug report. It should
  3725.      be posted with the `mysqlbug' script.  The example uses the `mysql'
  3726.      command-line tool. Note the use of the `\G' statement terminator
  3727.      for statements whose output width would otherwise exceed that of
  3728.      an 80-column display device.
  3729.  
  3730.           mysql> SHOW VARIABLES;
  3731.           mysql> SHOW COLUMNS FROM ...\G
  3732.                  <output from SHOW COLUMNS>
  3733.           mysql> EXPLAIN SELECT ...\G
  3734.                  <output from EXPLAIN>
  3735.           mysql> FLUSH STATUS;
  3736.           mysql> SELECT ...;
  3737.                  <A short version of the output from SELECT,
  3738.                  including the time taken to run the query>
  3739.           mysql> SHOW STATUS;
  3740.                  <output from SHOW STATUS>
  3741.  
  3742.    * If a bug or problem occurs while running `mysqld', try to provide
  3743.      an input script that will reproduce the anomaly.  This script
  3744.      should include any necessary source files.  The more closely the
  3745.      script can reproduce your situation, the better.  If you can make
  3746.      a reproducible test case, you should post it on
  3747.      `http://bugs.mysql.com/' for high-priority treatment.
  3748.  
  3749.      If you can't provide a script, you should at least include the
  3750.      output from `mysqladmin variables extended-status processlist' in
  3751.      your mail to provide some information on how your system is
  3752.      performing.
  3753.  
  3754.    * If you can't produce a test case with only a few rows, or if the
  3755.      test table is too big to be mailed to the mailing list (more than
  3756.      10 rows), you should dump your tables using `mysqldump' and create
  3757.      a `README' file that describes your problem.
  3758.  
  3759.      Create a compressed archive of your files using `tar' and `gzip'
  3760.      or `zip', and use FTP to transfer the archive to
  3761.      `ftp://ftp.mysql.com/pub/mysql/upload/'.  Then enter the problem
  3762.      into our bugs database at `http://bugs.mysql.com/'.
  3763.  
  3764.    * If you think that the MySQL server produces a strange result from
  3765.      a query, include not only the result, but also your opinion of
  3766.      what the result should be, and an account describing the basis for
  3767.      your opinion.
  3768.  
  3769.    * When giving an example of the problem, it's better to use the
  3770.      variable names, table names, and so on that exist in your actual
  3771.      situation than to come up with new names.  The problem could be
  3772.      related to the name of a variable or table.  These cases are rare,
  3773.      perhaps, but it is better to be safe than sorry.  After all, it
  3774.      should be easier for you to provide an example that uses your
  3775.      actual situation, and it is by all means better for us.  In case
  3776.      you have data that you don't want to show to others, you can use
  3777.      FTP to transfer it to `ftp://ftp.mysql.com/pub/mysql/upload/'.  If
  3778.      the information is really top secret and you don't want to show it
  3779.      even to us, then go ahead and provide an example using other
  3780.      names, but please regard this as the last choice.
  3781.  
  3782.    * Include all the options given to the relevant programs, if
  3783.      possible.  For example, indicate the options that you use when you
  3784.      start the `mysqld' server as well as the options that you use to
  3785.      run any MySQL client programs.  The options to programs such as
  3786.      `mysqld' and `mysql', and to the `configure' script, are often
  3787.      keys to answers and are very relevant.  It is never a bad idea to
  3788.      include them.  If you use any modules, such as Perl or PHP, please
  3789.      include the version numbers of those as well.
  3790.  
  3791.    * If your question is related to the privilege system, please
  3792.      include the output of `mysqlaccess', the output of `mysqladmin
  3793.      reload', and all the error messages you get when trying to
  3794.      connect.  When you test your privileges, you should first run
  3795.      `mysqlaccess'.  After this, execute `mysqladmin reload version'
  3796.      and try to connect with the program that gives you trouble.
  3797.      `mysqlaccess' can be found in the `bin' directory under your MySQL
  3798.      installation directory.
  3799.  
  3800.    * If you have a patch for a bug, do include it.  But don't assume
  3801.      that the patch is all we need, or that we will use it, if you
  3802.      don't provide some necessary information such as test cases
  3803.      showing the bug that your patch fixes.  We might find problems
  3804.      with your patch or we might not understand it at all; if so, we
  3805.      can't use it.
  3806.  
  3807.      If we can't verify exactly what the purpose of the patch is, we
  3808.      won't use it.  Test cases will help us here.  Show that the patch
  3809.      will handle all the situations that may occur.  If we find a
  3810.      borderline case (even a rare one) where the patch won't work, it
  3811.      may be useless.
  3812.  
  3813.    * Guesses about what the bug is, why it occurs, or what it depends on
  3814.      are usually wrong.  Even the MySQL team can't guess such things
  3815.      without first using a debugger to determine the real cause of a
  3816.      bug.
  3817.  
  3818.    * Indicate in your bug report that you have checked the reference
  3819.      manual and mail archive so that others know you have tried to
  3820.      solve the problem yourself.
  3821.  
  3822.    * If you get a `parse error', please check your syntax closely.  If
  3823.      you can't find something wrong with it, it's extremely likely that
  3824.      your current version of MySQL Server doesn't support the syntax
  3825.      you are using.  If you are using the current version and the
  3826.      manual at `http://dev.mysql.com/doc/' doesn't cover the syntax you
  3827.      are using, MySQL Server doesn't support your query.  In this case,
  3828.      your only options are to implement the syntax yourself or email
  3829.      <licensing@mysql.com> and ask for an offer to implement it.
  3830.  
  3831.      If the manual covers the syntax you are using, but you have an
  3832.      older version of MySQL Server, you should check the MySQL change
  3833.      history to see when the syntax was implemented.  In this case, you
  3834.      have the option of upgrading to a newer version of MySQL Server.
  3835.      *Note News::.
  3836.  
  3837.    * If your problem is that your data appears corrupt or you get errors
  3838.      when you access a particular table, you should first check and
  3839.      then try to repair your tables with `CHECK TABLE' and `REPAIR
  3840.      TABLE' or with `myisamchk'.  *Note MySQL Database Administration::.
  3841.  
  3842.      If you are running Windows, please verify that
  3843.      `lower_case_table_names' is 1 or 2 with `SHOW VARIABLES LIKE
  3844.      'lower_case_table_names''.
  3845.  
  3846.    * If you often get corrupted tables, you should try to find out when
  3847.      and why this happens.  In this case, the error log in the MySQL
  3848.      data directory may contain some information about what happened.
  3849.      (This is the file with the `.err' suffix in the name.)  *Note
  3850.      Error log::.  Please include any relevant information from this
  3851.      file in your bug report.  Normally `mysqld' should _never_ crash a
  3852.      table if nothing killed it in the middle of an update.  If you can
  3853.      find the cause of `mysqld' dying, it's much easier for us to
  3854.      provide you with a fix for the problem.  *Note What is crashing::.
  3855.  
  3856.    * If possible, download and install the most recent version of MySQL
  3857.      Server and check whether it solves your problem.  All versions of
  3858.      the MySQL software are thoroughly tested and should work without
  3859.      problems.  We believe in making everything as backward-compatible
  3860.      as possible, and you should be able to switch MySQL versions
  3861.      without difficulty.  *Note Which version::.
  3862.  
  3863. If you are a support customer, please cross-post the bug report to
  3864. <mysql-support@mysql.com> for higher-priority treatment, as well as to
  3865. the appropriate mailing list to see whether someone else has
  3866. experienced (and perhaps solved) the problem.
  3867.  
  3868. For information on reporting bugs in MyODBC, see *Note MyODBC bug
  3869. report::.
  3870.  
  3871. For solutions to some common problems, see *Note Problems::.
  3872.  
  3873. When answers are sent to you individually and not to the mailing list,
  3874. it is considered good etiquette to summarize the answers and send the
  3875. summary to the mailing list so that others may have the benefit of
  3876. responses you received that helped you solve your problem.
  3877.  
  3878. Guidelines for Answering Questions on the Mailing List
  3879. ......................................................
  3880.  
  3881. If you consider your answer to have broad interest, you may want to
  3882. post it to the mailing list instead of replying directly to the
  3883. individual who asked.  Try to make your answer general enough that
  3884. people other than the original poster may benefit from it.  When you
  3885. post to the list, please make sure that your answer is not a
  3886. duplication of a previous answer.
  3887.  
  3888. Try to summarize the essential part of the question in your reply;
  3889. don't feel obliged to quote the entire original message.
  3890.  
  3891. Please don't post mail messages from your browser with HTML mode turned
  3892. on.  Many users don't read mail with a browser.
  3893.  
  3894. MySQL Community Support on IRC (Internet Relay Chat)
  3895. ----------------------------------------------------
  3896.  
  3897. In addition to the various MySQL mailing lists, you can find experienced
  3898. community people on `IRC' (`Internet Relay Chat').  These are the best
  3899. networks/channels currently known to us:
  3900.  
  3901.    * *freenode* (see `http://www.freenode.net/' for servers)
  3902.         * `#mysql' Primarily MySQL questions, but other database and
  3903.           general SQL questions are welcome.  Questions about PHP, Perl
  3904.           or C in combination with MySQL are also common.
  3905.  
  3906.    * *EFnet* (see `http://www.efnet.org/' for servers)
  3907.         * `#mysql' MySQL questions.
  3908.  
  3909. If you are looking for IRC client software to connect to an IRC network,
  3910. take a look at `X-Chat' (`http://www.xchat.org/').  X-Chat (GPL
  3911. licensed) is available for Unix as well as for Windows platforms.
  3912.  
  3913. MySQL Standards Compliance
  3914. ==========================
  3915.  
  3916. This section describes how MySQL relates to the ANSI/ISO SQL standards.
  3917. MySQL Server has many extensions to the SQL standard, and here you will
  3918. find out what they are and how to use them.  You will also find
  3919. information about functionality missing from MySQL Server, and how to
  3920. work around some differences.
  3921.  
  3922. The SQL standard has been evolving since 1986 and several versions
  3923. exist. In this manual, "SQL-92" refers to the standard released in 1992,
  3924. "SQL:1999" refers to the standard released in 1999, and "SQL:2003"
  3925. refers to the current version of the standard.  We use the phrase "the
  3926. SQL standard" to mean the current version of the SQL Standard at any
  3927. time.
  3928.  
  3929. Our goal is to not restrict MySQL Server usability for any usage
  3930. without a very good reason for doing so.  Even if we don't have the
  3931. resources to perform  development for every possible use, we are always
  3932. willing to help and offer suggestions to people who are trying to use
  3933. MySQL Server in new territories.
  3934.  
  3935. One of our main goals with the product is to continue to work toward
  3936. compliance with the SQL standard, but without sacrificing speed or
  3937. reliability.  We are not afraid to add extensions to SQL or support for
  3938. non-SQL features if this greatly increases the usability of MySQL
  3939. Server for a large segment of our user base.  The `HANDLER' interface
  3940. in MySQL Server 4.0 is an example of this strategy. *Note `HANDLER':
  3941. HANDLER.
  3942.  
  3943. We will continue to support transactional and non-transactional
  3944. databases to satisfy both mission-critical 24/7 usage and heavy Web or
  3945. logging usage.
  3946.  
  3947. MySQL Server was originally designed to work with medium size databases
  3948. (10-100 million rows, or about 100MB per table) on small computer
  3949. systems.  Today MySQL Server handles terabyte-size databases, but the
  3950. code can also be compiled in a reduced version suitable for hand-held
  3951. and embedded devices.  The compact design of the MySQL server makes
  3952. development in both directions possible without any conflicts in the
  3953. source tree.
  3954.  
  3955. Currently, we are not targeting realtime support, although MySQL
  3956. replication capabilities already offer significant functionality.
  3957.  
  3958. Database cluster support now exists through third-party clustering
  3959. solutions as well as the integration of our acquired NDB Cluster
  3960. technology into a new storage engine, available from version 4.1.2.
  3961. *Note NDBCluster::.
  3962.  
  3963. We are also looking at providing XML support in the database server.
  3964.  
  3965. What Standards MySQL Follows
  3966. ----------------------------
  3967.  
  3968. We are aiming toward supporting the full ANSI/ISO SQL standard, but
  3969. without making concessions to speed and quality of the code.
  3970.  
  3971. ODBC levels 0-3.51.
  3972.  
  3973. Selecting SQL Modes
  3974. -------------------
  3975.  
  3976. The MySQL server can operate in different SQL modes, and can apply these
  3977. modes differentially for different clients. This allows an application
  3978. to tailor server operation to its own requirements.
  3979.  
  3980. Modes define what SQL syntax MySQL should support and what kind of
  3981. validation checks it should perform on the data.  This makes it easier
  3982. to use MySQL in a lot of different environments and to use MySQL
  3983. together with other database servers.
  3984.  
  3985. You can set the default SQL mode by starting `mysqld' with the
  3986. `--sql-mode="modes"' option. Beginning with MySQL 4.1, you can also
  3987. change the mode after startup time by setting the `sql_mode' variable
  3988. with a `SET [SESSION|GLOBAL] sql_mode='modes'' statement.
  3989.  
  3990. For more information on setting the server mode, see *Note Server SQL
  3991. mode::.
  3992.  
  3993. Running MySQL in ANSI Mode
  3994. --------------------------
  3995.  
  3996. You can tell `mysqld' to use the ANSI mode with the `--ansi' startup
  3997. option. *Note Server options::.
  3998.  
  3999. Running the server in ANSI mode is the same as starting it with these
  4000. options (specify the `--sql_mode' value on a single line):
  4001.  
  4002.      --transaction-isolation=SERIALIZABLE
  4003.      --sql-mode=REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,
  4004.      IGNORE_SPACE,ONLY_FULL_GROUP_BY
  4005.  
  4006. In MySQL 4.1, you can achieve the same effect with these two statements
  4007. (specify the `sql_mode' value on a single line):
  4008.  
  4009.      SET GLOBAL TRANSACTION ISOLATION LEVEL SERIALIZABLE;
  4010.      SET GLOBAL sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,
  4011.      IGNORE_SPACE,ONLY_FULL_GROUP_BY';
  4012.  
  4013. *Note SQL mode::.
  4014.  
  4015. In MySQL 4.1.1, the `sql_mode' options shown can be also be set with
  4016. this statement:
  4017.  
  4018.      SET GLOBAL sql_mode='ansi';
  4019.  
  4020. In this case, the value of the `sql_mode' variable will be set to all
  4021. options that are relevant for ANSI mode. You can check the result like
  4022. this:
  4023.  
  4024.      mysql> SET GLOBAL sql_mode='ansi';
  4025.      mysql> SELECT @@global.sql_mode;
  4026.              -> 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,
  4027.                  IGNORE_SPACE,ONLY_FULL_GROUP_BY,ANSI';
  4028.  
  4029. MySQL Extensions to Standard SQL
  4030. --------------------------------
  4031.  
  4032. MySQL Server includes some extensions that you probably will not find in
  4033. other SQL databases.  Be warned that if you use them, your code will
  4034. not be portable to other SQL servers.  In some cases, you can write
  4035. code that includes MySQL extensions, but is still portable, by using
  4036. comments of the form `/*! ... */'.  In this case, MySQL Server will
  4037. parse and execute the code within the comment as it would any other
  4038. MySQL statement, but other SQL servers will ignore the extensions.  For
  4039. example:
  4040.  
  4041.      SELECT /*! STRAIGHT_JOIN */ col_name FROM table1,table2 WHERE ...
  4042.  
  4043. If you add a version number after the `!' character, the syntax within
  4044. the comment will be executed only if the MySQL version is equal to or
  4045. newer than the specified version number:
  4046.  
  4047.      CREATE /*!32302 TEMPORARY */ TABLE t (a INT);
  4048.  
  4049. This means that if you have Version 3.23.02 or newer, MySQL Server will
  4050. use the `TEMPORARY' keyword.
  4051.  
  4052. The following descriptions list MySQL extensions, organized by category.
  4053.  
  4054. Organization of data on disk
  4055.      MySQL Server maps each database to a directory under the MySQL
  4056.      data directory, and tables within a database to filenames in the
  4057.      database directory.  This has a few implications:
  4058.  
  4059.         * Database names and table names are case sensitive in MySQL
  4060.           Server on operating systems that have case-sensitive
  4061.           filenames (such as most Unix systems). *Note Name case
  4062.           sensitivity::.
  4063.  
  4064.         * You can use standard system commands to back up, rename,
  4065.           move, delete, and copy tables that are managed by the
  4066.           `MyISAM' or `ISAM' storage engines.  For example, to rename a
  4067.           `MyISAM' table, rename the `.MYD', `.MYI', and `.frm' files
  4068.           to which the table corresponds.
  4069.  
  4070.      Database, table, index, column, or alias names may begin with a
  4071.      digit (but may not consist solely of digits).
  4072.  
  4073. General language syntax
  4074.         * Strings may be enclosed by either `"' or `'', not just by `''.
  4075.  
  4076.         * Use of `\' as an escape character in strings.
  4077.  
  4078.         * In SQL statements, you can access tables from different
  4079.           databases with the DB_NAME.TBL_NAME syntax.  Some SQL servers
  4080.           provide the same functionality but call this `User space'.
  4081.           MySQL Server doesn't support tablespaces such as used in
  4082.           statements like this: `CREATE TABLE ralph.my_table...IN
  4083.           my_tablespace'.
  4084.  
  4085.  
  4086. SQL statement syntax
  4087.         * The `ANALYZE TABLE', `CHECK TABLE', `OPTIMIZE TABLE', and
  4088.           `REPAIR TABLE' statements.
  4089.  
  4090.         * The `CREATE DATABASE' and `DROP DATABASE' statements.  *Note
  4091.           `CREATE DATABASE': CREATE DATABASE.
  4092.  
  4093.         * The `DO' statement.
  4094.  
  4095.         * `EXPLAIN SELECT' to get a description of how tables are
  4096.           joined.
  4097.  
  4098.         * The `FLUSH' and `RESET' statements.
  4099.  
  4100.         * The `SET' statement. *Note `SET': SET OPTION.
  4101.  
  4102.         * The `SHOW' statement.  *Note `SHOW': SHOW.
  4103.  
  4104.         * Use of `LOAD DATA INFILE'. In many cases, this syntax is
  4105.           compatible with Oracle's `LOAD DATA INFILE'. *Note `LOAD
  4106.           DATA': LOAD DATA.
  4107.  
  4108.         * Use of `RENAME TABLE'. *Note `RENAME TABLE': RENAME TABLE.
  4109.  
  4110.         * Use of `REPLACE' instead of `DELETE' + `INSERT'.  *Note
  4111.           `REPLACE': REPLACE.
  4112.  
  4113.         * Use of `CHANGE col_name', `DROP col_name', or `DROP INDEX',
  4114.           `IGNORE' or `RENAME' in an `ALTER TABLE' statement.  Use of
  4115.           multiple `ADD', `ALTER', `DROP', or `CHANGE' clauses in an
  4116.           `ALTER TABLE' statement.  *Note `ALTER TABLE': ALTER TABLE.
  4117.  
  4118.         * Use of index names, indexes on a prefix of a field, and use of
  4119.           `INDEX' or `KEY' in a `CREATE TABLE' statement. *Note `CREATE
  4120.           TABLE': CREATE TABLE.
  4121.  
  4122.         * Use of `TEMPORARY' or `IF NOT EXISTS' with `CREATE TABLE'.
  4123.  
  4124.         * Use of `IF EXISTS' with `DROP TABLE'.
  4125.  
  4126.         * You can drop multiple tables with a single `DROP TABLE'
  4127.           statement.
  4128.  
  4129.         * The `ORDER BY' and `LIMIT' clauses of the `UPDATE' and
  4130.           `DELETE' statements.
  4131.  
  4132.         * `INSERT INTO ... SET col_name = ...' syntax.
  4133.  
  4134.         * The `DELAYED' clause of the `INSERT' and `REPLACE' statements.
  4135.  
  4136.         * The `LOW_PRIORITY' clause of the `INSERT', `REPLACE',
  4137.           `DELETE', and `UPDATE' statements.
  4138.  
  4139.         * Use of `INTO OUTFILE' and `STRAIGHT_JOIN' in a `SELECT'
  4140.           statement. *Note `SELECT': SELECT.
  4141.  
  4142.         * The `SQL_SMALL_RESULT' option in a `SELECT' statement.
  4143.  
  4144.         * You don't need to name all selected columns in the `GROUP BY'
  4145.           part.  This gives better performance for some very specific,
  4146.           but quite normal queries.  *Note Group by functions and
  4147.           modifiers::.
  4148.  
  4149.         * You can specify `ASC' and `DESC' with `GROUP BY'.
  4150.  
  4151.         * The ability to set variables in a statement with the `:='
  4152.           assignment operator:
  4153.                mysql> SELECT @a:=SUM(total),@b=COUNT(*),@a/@b AS avg
  4154.                    -> FROM test_table;
  4155.                mysql> SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
  4156.  
  4157.  
  4158. Column types
  4159.         * The column types `MEDIUMINT', `SET', `ENUM', and the
  4160.           different `BLOB' and `TEXT' types.
  4161.  
  4162.         * The column attributes `AUTO_INCREMENT', `BINARY', `NULL',
  4163.           `UNSIGNED', and `ZEROFILL'.
  4164.  
  4165. Functions and operators
  4166.         * To make it easier for users who come from other SQL
  4167.           environments, MySQL Server supports aliases for many
  4168.           functions. For example, all string functions support both
  4169.           standard SQL syntax and ODBC syntax.
  4170.  
  4171.         * MySQL Server understands the `||' and `&&' operators to mean
  4172.           logical OR and AND, as in the C programming language.  In
  4173.           MySQL Server, `||' and `OR' are synonyms, as are `&&' and
  4174.           `AND'.  Because of this nice syntax, MySQL Server doesn't
  4175.           support the standard SQL `||' operator for string
  4176.           concatenation; use `CONCAT()' instead. Because `CONCAT()'
  4177.           takes any number of arguments, it's easy to convert use of
  4178.           the `||' operator to MySQL Server.
  4179.  
  4180.         * Use of `COUNT(DISTINCT list)' where `list' has more than one
  4181.           element.
  4182.  
  4183.         * All string comparisons are case-insensitive by default, with
  4184.           sort ordering determined by the current character set
  4185.           (ISO-8859-1 Latin1 by default).  If you don't like this, you
  4186.           should declare your columns with the `BINARY' attribute or
  4187.           use the `BINARY' cast, which causes comparisons to be done
  4188.           using the underlying character code values rather then a
  4189.           lexical ordering.
  4190.  
  4191.         * The `%' operator is a synonym for `MOD()'.  That is, `N % M'
  4192.           is equivalent to `MOD(N,M)'.  `%' is supported for C
  4193.           programmers and for compatibility with PostgreSQL.
  4194.  
  4195.         * The `=', `<>', `<=' ,`<', `>=',`>', `<<', `>>', `<=>', `AND',
  4196.           `OR', or `LIKE' operators may be used in column comparisons
  4197.           to the left of the `FROM' in `SELECT' statements.  For
  4198.           example:
  4199.  
  4200.                mysql> SELECT col1=1 AND col2=2 FROM TBL_NAME;
  4201.  
  4202.         * The `LAST_INSERT_ID()' function that returns the most recent
  4203.           `AUTO_INCREMENT' value.  *Note Information functions::.
  4204.  
  4205.         * `LIKE' is allowed on numeric columns.
  4206.  
  4207.         * The `REGEXP' and `NOT REGEXP' extended regular expression
  4208.           operators.
  4209.  
  4210.         * `CONCAT()' or `CHAR()' with one argument or more than two
  4211.           arguments.  (In MySQL Server, these functions can take any
  4212.           number of arguments.)
  4213.  
  4214.         * The `BIT_COUNT()', `CASE', `ELT()', `FROM_DAYS()',
  4215.           `FORMAT()', `IF()', `PASSWORD()', `ENCRYPT()', `MD5()',
  4216.           `ENCODE()', `DECODE()', `PERIOD_ADD()', `PERIOD_DIFF()',
  4217.           `TO_DAYS()', and `WEEKDAY()' functions.
  4218.  
  4219.         * Use of `TRIM()' to trim substrings.  Standard SQL supports
  4220.           removal of single characters only.
  4221.  
  4222.         * The `GROUP BY' functions `STD()', `BIT_OR()', `BIT_AND()',
  4223.           `BIT_XOR()', and `GROUP_CONCAT()'.  *Note Group by functions
  4224.           and modifiers::.
  4225.  
  4226. For a prioritized list indicating when new extensions will be added to
  4227. MySQL Server, you should consult the online MySQL TODO list at
  4228. `http://dev.mysql.com/doc/mysql/en/TODO.html'.  That is the latest
  4229. version of the TODO list in this manual. *Note TODO::.
  4230.  
  4231. MySQL Differences from Standard SQL
  4232. -----------------------------------
  4233.  
  4234. We try to make MySQL Server follow the ANSI SQL standard and the ODBC
  4235. SQL standard, but MySQL Server performs operations differently in some
  4236. cases:
  4237.  
  4238.    * For `VARCHAR' columns, trailing spaces are removed when the value
  4239.      is stored. *Note Bugs::.
  4240.  
  4241.    * In some cases, `CHAR' columns are silently converted to `VARCHAR'
  4242.      columns when you define a table or alter its structure.  *Note
  4243.      Silent column changes::.
  4244.  
  4245.    * Privileges for a table are not automatically revoked when you
  4246.      delete a table. You must explicitly issue a `REVOKE' statement to
  4247.      revoke privileges for a table. *Note `GRANT': GRANT.
  4248.  
  4249. Subqueries
  4250. ..........
  4251.  
  4252. MySQL 4.1 supports subqueries and derived tables.  A "subquery" is a
  4253. `SELECT' statement nested within another statement.  A "derived table"
  4254. (an unnamed view) is a subquery in the `FROM' clause of another
  4255. statement.  *Note Subqueries::.
  4256.  
  4257. For MySQL versions older than 4.1, most subqueries can be rewritten
  4258. using joins or other methods.  See *Note Rewriting subqueries:: for
  4259. examples that show how to do this.
  4260.  
  4261. `SELECT INTO TABLE'
  4262. ...................
  4263.  
  4264. MySQL Server doesn't support the Sybase SQL extension: `SELECT ... INTO
  4265. TABLE ...'.  Instead, MySQL Server supports the standard SQL syntax
  4266. `INSERT INTO ... SELECT ...', which is basically the same thing. *Note
  4267. `INSERT SELECT': INSERT SELECT.
  4268.  
  4269.      INSERT INTO tbl_temp2 (fld_id)
  4270.          SELECT tbl_temp1.fld_order_id
  4271.          FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
  4272.  
  4273. Alternatively, you can use `SELECT INTO OUTFILE ...' or `CREATE TABLE
  4274. ... SELECT'.
  4275.  
  4276. From version 5.0, MySQL supports `SELECT ... INTO' with user variables.
  4277. The same syntax may also be used inside stored procedures using cursors
  4278. and local variables.  *Note SELECT INTO Statement::.
  4279.  
  4280. Transactions and Atomic Operations
  4281. ..................................
  4282.  
  4283. MySQL Server (version 3.23-max and all versions 4.0 and above) supports
  4284. transactions with the `InnoDB' and `BDB' transactional storage engines.
  4285. `InnoDB' provides _full_ `ACID' compliance.  *Note Storage engines::.
  4286.  
  4287. The other non-transactional storage engines in MySQL Server (such as
  4288. `MyISAM') follow a different paradigm for data integrity called "atomic
  4289. operations." In transactional terms, `MyISAM' tables effectively always
  4290. operate in `AUTOCOMMIT=1' mode.  Atomic operations often offer
  4291. comparable integrity with higher performance.
  4292.  
  4293. With MySQL Server supporting both paradigms, you can decide whether your
  4294. applications are best served by the speed of atomic operations or the
  4295. use of transactional features. This choice can be made on a per-table
  4296. basis.
  4297.  
  4298. As noted, the trade-off for transactional versus non-transactional table
  4299. types lies mostly in performance. Transactional tables have
  4300. significantly higher memory and diskspace requirements, and more CPU
  4301. overhead.  On the other hand, transactional table types such as
  4302. `InnoDB' also offer many significant features. MySQL Server's modular
  4303. design allows the concurrent use of different storage engines to suit
  4304. different requirements and deliver optimum performance in all
  4305. situations.
  4306.  
  4307. But how do you use the features of MySQL Server to maintain rigorous
  4308. integrity even with the non-transactional `MyISAM' tables, and how do
  4309. these features compare with the transactional table types?
  4310.  
  4311.   1. If your applications are written in a way that is dependent on
  4312.      being able to call `ROLLBACK' rather than `COMMIT' in critical
  4313.      situations, transactions are more convenient. Transactions also
  4314.      ensure that unfinished updates or corrupting activities are not
  4315.      committed to the database; the server is given the opportunity to
  4316.      do an automatic rollback and your database is saved.
  4317.  
  4318.      If you use non-transactional tables, MySQL Server in almost all
  4319.      cases allows you to resolve potential problems by including simple
  4320.      checks before updates and by running simple scripts that check the
  4321.      databases for inconsistencies and automatically repair or warn if
  4322.      such an inconsistency occurs. Note that just by using the MySQL
  4323.      log or even adding one extra log, you can normally fix tables
  4324.      perfectly with no data integrity loss.
  4325.  
  4326.   2. More often than not, critical transactional updates can be
  4327.      rewritten to be atomic. Generally speaking, all integrity problems
  4328.      that transactions solve can be done with `LOCK TABLES' or atomic
  4329.      updates, ensuring that you never will get an automatic abort from
  4330.      the server, which is a common problem with transactional database
  4331.      systems.
  4332.  
  4333.   3. Even a transactional system can lose data if the server goes down.
  4334.      The difference between different systems lies in just how small the
  4335.      time-lag is where they could lose data. No system is 100% secure,
  4336.      only "secure enough." Even Oracle, reputed to be the safest of
  4337.      transactional database systems, is reported to sometimes lose data
  4338.      in such situations.
  4339.  
  4340.      To be safe with MySQL Server, whether or not using transactional
  4341.      tables, you only need to have backups and have binary logging
  4342.      turned on. With this you can recover from any situation that you
  4343.      could with any other transactional database system.  It is always
  4344.      good to have backups, regardless of which database system you use.
  4345.  
  4346. The transactional paradigm has its benefits and its drawbacks. Many
  4347. users and application developers depend on the ease with which they can
  4348. code around problems where an abort appears to be, or is necessary.
  4349. However, even if you are new to the atomic operations paradigm, or more
  4350. familiar with transactions, do consider the speed benefit that
  4351. non-transactional tables can offer on the order of three to five times
  4352. the speed of the fastest and most optimally tuned transactional tables.
  4353.  
  4354. In situations where integrity is of highest importance, MySQL Server
  4355. offers transaction-level reliability and integrity even for
  4356. non-transactional tables.  If you lock tables with `LOCK TABLES', all
  4357. updates will stall until any integrity checks are made. If you obtain a
  4358. `READ LOCAL' lock (as opposed to a write lock) for a table that allows
  4359. concurrent inserts at the end of the table, reads are allowed, as are
  4360. inserts by other clients.  The new inserted records will not be seen by
  4361. the client that has the read lock until it releases the lock.  With
  4362. `INSERT DELAYED', you can queue inserts into a local queue, until the
  4363. locks are released, without having the client wait for the insert to
  4364. complete. *Note INSERT DELAYED::.
  4365.  
  4366. "Atomic," in the sense that we mean it, is nothing magical. It only
  4367. means that you can be sure that while each specific update is running,
  4368. no other user can interfere with it, and there will never be an
  4369. automatic rollback (which can happen with transactional tables if you
  4370. are not very careful).  MySQL Server also guarantees that there will
  4371. not be any dirty reads.
  4372.  
  4373. Following are some techniques for working with non-transactional tables:
  4374.  
  4375.    * Loops that need transactions normally can be coded with the help of
  4376.      `LOCK TABLES', and you don't need cursors to update records on the
  4377.      fly.
  4378.  
  4379.    * To avoid using `ROLLBACK', you can use the following strategy:
  4380.  
  4381.        1. Use `LOCK TABLES' to lock all the tables you want to access.
  4382.  
  4383.        2. Test the conditions that must be true before performing the
  4384.           update.
  4385.  
  4386.        3. Update if everything is okay.
  4387.  
  4388.        4. Use `UNLOCK TABLES' to release your locks.
  4389.  
  4390.      This is usually a much faster method than using transactions with
  4391.      possible rollbacks, although not always. The only situation this
  4392.      solution doesn't handle is when someone kills the threads in the
  4393.      middle of an update. In this case, all locks will be released but
  4394.      some of the updates may not have been executed.
  4395.  
  4396.    * You can also use functions to update records in a single operation.
  4397.      You can get a very efficient application by using the following
  4398.      techniques:
  4399.  
  4400.         * Modify columns relative to their current value.
  4401.  
  4402.         * Update only those columns that actually have changed.
  4403.  
  4404.      For example, when we are doing updates to some customer
  4405.      information, we update only the customer data that has changed and
  4406.      test only that none of the changed data, or data that depends on
  4407.      the changed data, has changed compared to the original row. The
  4408.      test for changed data is done with the `WHERE' clause in the
  4409.      `UPDATE' statement. If the record wasn't updated, we give the
  4410.      client a message: "Some of the data you have changed has been
  4411.      changed by another user." Then we show the old row versus the new
  4412.      row in a window so that the user can decide which version of the
  4413.      customer record to use.
  4414.  
  4415.      This gives us something that is similar to column locking but is
  4416.      actually even better because we only update some of the columns,
  4417.      using values that are relative to their current values.  This
  4418.      means that typical `UPDATE' statements look something like these:
  4419.  
  4420.           UPDATE tablename SET pay_back=pay_back+125;
  4421.           
  4422.           UPDATE customer
  4423.             SET
  4424.               customer_date='current_date',
  4425.               address='new address',
  4426.               phone='new phone',
  4427.               money_owed_to_us=money_owed_to_us-125
  4428.             WHERE
  4429.               customer_id=id AND address='old address' AND phone='old phone';
  4430.  
  4431.      This is very efficient and works even if another client has
  4432.      changed the values in the `pay_back' or `money_owed_to_us' columns.
  4433.  
  4434.    * In many cases, users have wanted `LOCK TABLES' and/or `ROLLBACK'
  4435.      for the purpose of managing unique identifiers.  This can be
  4436.      handled much more efficiently without locking or rolling back by
  4437.      using an `AUTO_INCREMENT' column and either the `LAST_INSERT_ID()'
  4438.      SQL function or the `mysql_insert_id()' C API function.  *Note
  4439.      Information functions::.  *Note `mysql_insert_id()':
  4440.      mysql_insert_id.
  4441.  
  4442.      You can generally code around the need for row-level locking. Some
  4443.      situations really do need it, and `InnoDB' tables support
  4444.      row-level locking. With `MyISAM' tables, you can use a flag column
  4445.      in the table and do something like the following:
  4446.  
  4447.           UPDATE TBL_NAME SET row_flag=1 WHERE id=ID;
  4448.  
  4449.      MySQL returns 1 for the number of affected rows if the row was
  4450.      found and `row_flag' wasn't already 1 in the original row.
  4451.  
  4452.      You can think of it as though MySQL Server changed the preceding
  4453.      query to:
  4454.  
  4455.           UPDATE TBL_NAME SET row_flag=1 WHERE id=ID AND row_flag <> 1;
  4456.  
  4457. Stored Procedures and Triggers
  4458. ..............................
  4459.  
  4460. Stored procedures are implemented in MySQL version 5.0.  *Note Stored
  4461. Procedures::.
  4462.  
  4463. Triggers are currently being implemented, with basic functionality in
  4464. MySQL 5.0, with further development planned for MySQL 5.1.
  4465.  
  4466. Foreign Keys
  4467. ............
  4468.  
  4469. In MySQL Server 3.23.44 and up, the `InnoDB' storage engine supports
  4470. checking of foreign key constraints, including `CASCADE', `ON DELETE',
  4471. and `ON UPDATE'. *Note InnoDB foreign key constraints::.
  4472.  
  4473. For storage engines other than `InnoDB', MySQL Server parses the
  4474. `FOREIGN KEY' syntax in `CREATE TABLE' statements, but does not use or
  4475. store it. In the future, the implementation will be extended to store
  4476. this information in the table specification file so that it may be
  4477. retrieved by `mysqldump' and ODBC.  At a later stage, foreign key
  4478. constraints will be implemented for `MyISAM' tables as well.
  4479.  
  4480. Foreign key enforcement offers several benefits to database developers:
  4481.  
  4482.    * Assuming proper design of the relationships, foreign key
  4483.      constraints make it more difficult for a programmer to introduce
  4484.      an inconsistency into the database.
  4485.  
  4486.    * Centralized checking of constraints by the database server makes it
  4487.      unnecessary to perform these checks on the application side. This
  4488.      eliminates the possibility that different applications may not all
  4489.      check the constraints in the same way.
  4490.  
  4491.    * Using cascading updates and deletes can simplify the application
  4492.      code.
  4493.  
  4494.    * Properly designed foreign key rules aid in documenting
  4495.      relationships between tables.
  4496.  
  4497. Do keep in mind that these benefits come at the cost of additional
  4498. overhead for the database server to perform the necessary checks.
  4499. Additional checking by the server affects performance, which for some
  4500. applications may be sufficiently undesirable as to be avoided if
  4501. possible.  (Some major commercial applications have coded the
  4502. foreign-key logic at the application level for this reason.)
  4503.  
  4504. MySQL gives database developers the choice of which approach to use. If
  4505. you don't need foreign keys and want to avoid the overhead associated
  4506. with enforcing referential integrity, you can choose another table type
  4507. instead, such as `MyISAM'. (For example, the `MyISAM' storage engine
  4508. offers very fast performance for applications that perform only
  4509. `INSERT' and `SELECT' operations, because the inserts can be performed
  4510. concurrently with retrievals.  *Note Table locking::.)
  4511.  
  4512. If you choose not to take advantage of referential integrity checks,
  4513. keep the following considerations in mind:
  4514.  
  4515.    * In the absence of server-side foreign key relationship checking,
  4516.      the application itself must handle relationship issues.  For
  4517.      example, it must take care to insert rows into tables in the proper
  4518.      order, and to avoid creating orphaned child records. It must also
  4519.      be able to recover from errors that occur in the middle of
  4520.      multiple-record insert operations.
  4521.  
  4522.    * If `ON DELETE' is the only referential integrity capability an
  4523.      application needs, note that as of MySQL Server 4.0, you can use
  4524.      multiple-table `DELETE' statements to delete rows from many tables
  4525.      with a single statement. *Note `DELETE': DELETE.
  4526.  
  4527.    * A workaround for the lack of `ON DELETE' is to add the appropriate
  4528.      `DELETE' statement to your application when you delete records
  4529.      from a table that has a foreign key. In practice, this is often as
  4530.      quick as using foreign keys, and is more portable.
  4531.  
  4532.  
  4533. Be aware that the use of foreign keys can in some instances lead to
  4534. problems:
  4535.  
  4536.    * Foreign key support addresses many referential integrity issues,
  4537.      but it is still necessary to design key relationships carefully to
  4538.      avoid circular rules or incorrect combinations of cascading
  4539.      deletes.
  4540.  
  4541.    * It is not uncommon for a DBA to create a topology of relationships
  4542.      that makes it difficult to restore individual tables from a backup.
  4543.      (MySQL alleviates this difficulty by allowing you to temporarily
  4544.      disable foreign key checks when reloading a table that depends on
  4545.      other tables.  *Note InnoDB foreign key constraints::.  As of
  4546.      MySQL 4.1.1, `mysqldump' generates dump files that take advantage
  4547.      of this capability automatically when reloaded.)
  4548.  
  4549. Note that foreign keys in SQL are used to check and enforce referential
  4550. integrity, not to join tables.  If you want to get results from multiple
  4551. tables from a `SELECT' statement, you do this by performing a join
  4552. between them:
  4553.  
  4554.      SELECT * FROM t1, t2 WHERE t1.id = t2.id;
  4555.  
  4556. *Note `JOIN': JOIN. *Note example-Foreign keys::.
  4557.  
  4558. The `FOREIGN KEY' syntax without `ON DELETE ...' is often used by ODBC
  4559. applications to produce automatic `WHERE' clauses.
  4560.  
  4561. Views
  4562. .....
  4563.  
  4564. Views (updatable) are being implemented in the 5.0 version of MySQL
  4565. Server.  They are already available in binary releases from 5.0.1 and
  4566. up.  *Note CREATE VIEW::.
  4567.  
  4568. Views are useful for allowing users to access a set of relations
  4569. (tables) as if it were a single table, and limiting their access to
  4570. just that.  Views can also be used to restrict access to rows (a subset
  4571. of a particular table).  For access control to columns, you can also
  4572. use the sophisticated privilege system in MySQL Server.  *Note
  4573. Privilege system::.
  4574.  
  4575. In designing an implementation of views, our ambitious goal, as much as
  4576. is possible within the confines of SQL, has been full compliance with
  4577. "Codd's Rule #6" for relational database systems: "All views that are
  4578. theoretically updatable, should in practice also be updatable."
  4579.  
  4580. `--' as the Start of a Comment
  4581. ..............................
  4582.  
  4583. Some other SQL databases use `--' to start comments.  MySQL Server uses
  4584. `#' as the start comment character. You can also use the C comment
  4585. style `/* this is a comment */' with MySQL Server.  *Note Comments::.
  4586.  
  4587. MySQL Server 3.23.3 and above support the `--' comment style, provided
  4588. the comment is followed by a space (or by a control character such as a
  4589. newline). The requirement for a space is to prevent problems with
  4590. automatically generated SQL queries that have used something like the
  4591. following code, where we automatically insert the value of the payment
  4592. for `!payment!':
  4593.  
  4594.      UPDATE account SET credit=credit-!payment!
  4595.  
  4596. Think about what happens if the value of `payment' is a negative value
  4597. such as `-1':
  4598.  
  4599.      UPDATE account SET credit=credit--1
  4600.  
  4601. `credit--1' is a legal expression in SQL, but if `--' is interpreted as
  4602. the start of a comment, part of the expression is discarded. The result
  4603. is a statement that has a completely different meaning than intended:
  4604.  
  4605.      UPDATE account SET credit=credit
  4606.  
  4607. The statement produces no change in value at all!  This illustrates that
  4608. allowing comments to start with `--' can have serious consequences.
  4609.  
  4610. Using our implementation of this method of commenting in MySQL Server
  4611. 3.23.3 and up, `credit--1' is actually safe.
  4612.  
  4613. Another safe feature is that the `mysql' command-line client removes
  4614. all lines that start with `--'.
  4615.  
  4616. The following information is relevant only if you are running a MySQL
  4617. version earlier than 3.23.3:
  4618.  
  4619. If you have an SQL program in a text file that contains `--' comments,
  4620. you should use the `replace' utility as follows to convert the comments
  4621. to use `#' characters:
  4622.  
  4623.      shell> replace " --" " #" < text-file-with-funny-comments.sql \
  4624.               | mysql DB_NAME
  4625.  
  4626. instead of the usual:
  4627.  
  4628.      shell> mysql DB_NAME < text-file-with-funny-comments.sql
  4629.  
  4630. You can also edit the command file "in place" to change the `--'
  4631. comments to `#' comments:
  4632.  
  4633.      shell> replace " --" " #" -- text-file-with-funny-comments.sql
  4634.  
  4635. Change them back with this command:
  4636.  
  4637.      shell> replace " #" " --" -- text-file-with-funny-comments.sql
  4638.  
  4639. How MySQL Deals with Constraints
  4640. --------------------------------
  4641.  
  4642. MySQL allows you to work both with transactional tables that allow
  4643. rollback and with non-transactional tables that do not. Because of this,
  4644. constraint handling is a bit different in MySQL than in other databases.
  4645. We must handle the case when you have inserted or updated a lot of rows
  4646. in a non-transactional table for which changes cannot be rolled back
  4647. when an error occurs.
  4648.  
  4649. The basic philosophy is that MySQL Server tries to produce an error for
  4650. anything that it can detect while parsing a statement to be executed,
  4651. and tries to recover from any errors that occur while executing the
  4652. statement.  We do this in most cases, but not yet for all. *Note TODO
  4653. future::.
  4654.  
  4655. The options MySQL has when an error occurs are to stop the statement in
  4656. the middle or to recover as well as possible from the problem and
  4657. continue.  By default, the server follows the latter course. This
  4658. means, for example, that the server may coerce illegal values to the
  4659. closest legal values.
  4660.  
  4661. Beginning with MySQL 5.0.2, several SQL mode options are available to
  4662. provide greater control over how accepting to be of bad data values and
  4663. whether to continue executing a statement or abort it when errors
  4664. occur. Using these options, you can configure MySQL Server to act in a
  4665. more traditional fashion that is like other DBMSs that reject improper
  4666. input. The SQL mode can be set at runtime, which enables individual
  4667. clients to select the behavior most appropriate for their requirements.
  4668. *Note Server SQL mode::.
  4669.  
  4670. The following sections describe what happens for the different types of
  4671. constraints.
  4672.  
  4673. `PRIMARY KEY' and `UNIQUE' Index Constraints
  4674. ............................................
  4675.  
  4676. Normally, an error occurs when you try to `INSERT' or `UPDATE' a row
  4677. that causes a primary key, unique key, or foreign key violation.  If
  4678. you are using a transactional storage engine such as `InnoDB', MySQL
  4679. automatically rolls back the statement.  If you are using a
  4680. non-transactional storage engine, MySQL stops processing the statement
  4681. at the row for which the error occurred and leaves any remaining rows
  4682. unprocessed.
  4683.  
  4684. If you wish to ignore such key violations, MySQL supports an `IGNORE'
  4685. keyword for `INSERT' and `UPDATE'. In this case, MySQL ignores any key
  4686. violations and continues processing with the next row.  *Note `INSERT':
  4687. INSERT.  *Note `UPDATE': UPDATE.
  4688.  
  4689. You can get information about the number of rows actually inserted or
  4690. updated with the `mysql_info()' C API function.  *Note `mysql_info()':
  4691. mysql_info.  In MySQL 4.1 and up, you also can use the `SHOW WARNINGS'
  4692. statement.  *Note `SHOW WARNINGS': SHOW WARNINGS.
  4693.  
  4694. For the moment, only `InnoDB' tables support foreign keys.  *Note
  4695. InnoDB foreign key constraints::.  Foreign key support in `MyISAM'
  4696. tables is scheduled for implementation in MySQL 5.1.
  4697.  
  4698. Constraints on Invalid Data
  4699. ...........................
  4700.  
  4701. Before MySQL 5.0.2, MySQL is forgiving of illegal or improper data
  4702. values and coerces them to legal values for data entry. In MySQL 5.0.2
  4703. and up, that remains the default behavior, but you can select more
  4704. traditional treatment of bad values such that the server rejects them
  4705. and aborts the the statement in which they occur.  This section
  4706. describes the default (forgiving) behavior of MySQL, as well as the
  4707. newer strict SQL mode and how it differs.
  4708.  
  4709. The following holds true when you are not using strict mode.  If you
  4710. insert an "incorrect" value into a column, such as a `NULL' into a `NOT
  4711. NULL' column or a too-large numeric value into a numeric column, MySQL
  4712. sets the column to the "best possible value" instead of producing an
  4713. error:
  4714.  
  4715.    * If you try to store an out of range value in a numeric column,
  4716.      MySQL Server instead stores zero, the smallest possible value, or
  4717.      the largest possible value in the column.
  4718.  
  4719.    * For strings, MySQL stores either the empty string or the longest
  4720.      possible string that can be in the column.
  4721.  
  4722.    * If you try to store a string that doesn't start with a number into
  4723.      a numeric column, MySQL Server stores 0.
  4724.  
  4725.    * If you try to store `NULL' into a column that doesn't take `NULL'
  4726.      values, MySQL Server stores 0 or `''' (the empty string) instead.
  4727.  
  4728.    * MySQL allows you to store certain incorrect date values into
  4729.      `DATE' and `DATETIME' columns (such as `'2000-02-31'' or
  4730.      `'2000-02-00'').  The idea is that it's not the job of the SQL
  4731.      server to validate dates. If MySQL can store a date value and
  4732.      retrieve exactly the same value, MySQL stores it as given.  If the
  4733.      date is totally wrong (outside the server's ability to store it),
  4734.      the special date value `'0000-00-00'' is stored in the column
  4735.      instead.
  4736.  
  4737.    * If an `INSERT' statement specifies no value for a column, MySQL
  4738.      inserts its default value if the column definition includes an
  4739.      explicit `DEFAULT' clause. If the definition has no such `DEFAULT'
  4740.      clause, MySQL inserts the implicit default value for the column
  4741.      data type.  In general, this is the empty string for string
  4742.      columns, 0 for numeric columns, and `'0000-00-00'' for date
  4743.      columns.  Implicit default values are discussed in *Note `CREATE
  4744.      TABLE': CREATE TABLE.
  4745.  
  4746.  
  4747. The reason for the preceding rules is that we can't check these
  4748. conditions until the statement has begun executing.  We can't just roll
  4749. back if we encounter a problem after updating a few rows, because the
  4750. storage engine may not support rollback.  The option of terminating the
  4751. statement is not that good; in this case, the update would be "half
  4752. done," which is probably the worst possible scenario.  In this case,
  4753. it's better to "do the best you can" and then continue as if nothing
  4754. happened.
  4755.  
  4756. In MySQL 5.0.2 and up, you can select stricter treatment of input
  4757. values by using the `STRICT_TRANS_TABLES' or `STRICT_ALL_TABLES' SQL
  4758. modes.  *Note Server SQL mode::.
  4759.  
  4760. `STRICT_TRANS_TABLES' works like this: For transactional storage
  4761. engines, bad data values occurring anywhere in the statement causes the
  4762. to abort and roll back.  For non-transactional storage engines, the
  4763. statement aborts if the error occurs in the first row to be inserted or
  4764. updated.  (In this case, the statement can be regarded to leave the
  4765. table unchanged, just as for a transactional table.)  Errors in rows
  4766. after the first do not abort the statement. Instead, bad data values
  4767. are adjusted and result in warnings rather than errors.  In other words,
  4768. with `STRICT_TRANS_TABLES', a wrong value causes MySQL to roll back, if
  4769. it can, all updates done so far.
  4770.  
  4771. For stricter checking, enable `STRICT_ALL_TABLES'. This is the same as
  4772. `STRICT_TRANS_TABLES' except that for non-transactional storage engines,
  4773. errors abort the statement even for bad data in rows following the
  4774. first row.  This means that if an error occurs partway through a
  4775. multiple-row insert or update for a non-transactional table, a partial
  4776. update results.  Earlier rows are inserted or updated, but those from
  4777. the point of the error on are not.  To avoid this for non-transactional
  4778. tables, either use single-row statements or else use
  4779. `STRICT_TRANS_TABLES' if conversion warnings rather than errors are
  4780. acceptable.  To avoid problems in the first place, do not use MySQL to
  4781. check column content. It is safest (and often faster) to let the
  4782. application ensure that it passes only legal values to the database.
  4783.  
  4784. With either of the strict mode options, you can cause errors to be
  4785. treated as warnings by using `INSERT IGNORE' or `UPDATE IGNORE'.
  4786.  
  4787. `ENUM' and `SET' Constraints
  4788. ............................
  4789.  
  4790. `ENUM' and `SET' columns provide an efficient way to define columns
  4791. that can contain only a given set of values.  However, before MySQL
  4792. 5.0.2, `ENUM' and `SET' are not real constraints.  This is for the same
  4793. reasons that `NOT NULL' is not honored.  *Note constraint invalid
  4794. data::.
  4795.  
  4796. `ENUM' columns always have a default value. If you don't specify a
  4797. default value, then it will be `NULL' for columns that can have `NULL',
  4798. otherwise the first enumeration value is used as the default value.
  4799.  
  4800. If you insert an incorrect value into an `ENUM' column or if you force
  4801. a value into an `ENUM' column with `IGNORE', it is set to the reserved
  4802. enumeration value of `0', which is displayed as an empty string in
  4803. string context. *Note `ENUM': ENUM.
  4804.  
  4805. If you insert an incorrect value into a `SET' column, the incorrect
  4806. value is ignored. For example, if the column can contain the values
  4807. `'a'', `'b'', and `'c'', an attempt to assign `'a,x,b,y'' results in a
  4808. value of `'a,b''.  *Note `SET': SET.
  4809.  
  4810. As of MySQL 5.0.2, you can configure the server to use strict SQL mode.
  4811. *Note Server SQL mode::.  When strict mode is not enabled, values
  4812. entered into `ENUM' and `SET' columns are handled as just described for
  4813. MySQL 4.x.  However, if strict mode is enabled, the definition of a
  4814. `ENUM' or `SET' column does act as a constraint on values entered into
  4815. the column. An error occurs for values that do not satisify these
  4816. conditions:
  4817.  
  4818.    * An `ENUM' value must be one of those listed in the column
  4819.      definition, or the internal numeric equivalent thereof. The value
  4820.      cannot be the error value (that is, 0 or the empty string).  For a
  4821.      column defined as `ENUM('a','b','c')', values such as `''', `'d'',
  4822.      and `'ax'' are illegal and are rejected.
  4823.  
  4824.    * A `SET' value must be the empty string or a value consisting of
  4825.      one or more of the values listed in the column definition
  4826.      separated by commas.  For a column defined as `SET('a','b','c')',
  4827.      values such as `'d'', and `'a,b,c,d'' are illegal and are rejected.
  4828.  
  4829.  
  4830. Errors for invalid values can be suppressed in strict mode if you use
  4831. `INSERT IGNORE' or `UPDATE IGNORE'.  In this case, a warning is
  4832. generated rather than an error. For `ENUM', the value is inserted as the
  4833. error member (`0'). For `SET', the value is inserted as given except
  4834. that that any invalid substrings are deleted. For example, `'a,x,b,y''
  4835. results in a value of `'a,b'', as described earlier.
  4836.  
  4837. Known Errors and Design Deficiencies in MySQL
  4838. ---------------------------------------------
  4839.  
  4840. Errors in 3.23 Fixed in a Later MySQL Version
  4841. .............................................
  4842.  
  4843. The following known errors or bugs are not fixed in MySQL 3.23 because
  4844. fixing them would involve changing a lot of code that could introduce
  4845. other even worse bugs. The bugs are also classified as "not fatal" or
  4846. "bearable."
  4847.  
  4848.    * You should avoid using spaces at the end of column names because
  4849.      this can cause weird behavior. (Fixed in MySQL 4.0.) (Bug #4196)
  4850.  
  4851.    * You can get a deadlock (hung thread) if you use `LOCK TABLE' to
  4852.      lock multiple tables and then in the same connection use `DROP
  4853.      TABLE' to drop one of them while another thread is trying to lock
  4854.      it.  (To break the deadlock, you can use `KILL' to terminate any
  4855.      of the threads involved.)  This issue is resolved as of MySQL
  4856.      4.0.12.
  4857.  
  4858.    * `SELECT MAX(key_column) FROM t1,t2,t3...' where one of the tables
  4859.      are empty doesn't return `NULL' but instead returns the maximum
  4860.      value for the column.  This issue is resolved as of MySQL 4.0.11.
  4861.  
  4862.    * `DELETE FROM heap_table' without a `WHERE' clause doesn't work on
  4863.      a locked `HEAP' table.
  4864.  
  4865. Errors in 4.0 Fixed in a Later MySQL Version
  4866. ............................................
  4867.  
  4868. The following known errors or bugs are not fixed in MySQL 4.0 because
  4869. fixing them would involve changing a lot of code that could introduce
  4870. other even worse bugs. The bugs are also classified as "not fatal" or
  4871. "bearable."
  4872.  
  4873.    * In a `UNION', the first `SELECT' determines the type,
  4874.      `max_length', and `NULL' properties for the resulting columns.
  4875.      This issue is resolved as of MySQL 4.1.1; the property values are
  4876.      based on the rows from all `UNION' parts.
  4877.  
  4878.    * In `DELETE' with many tables, you can't refer to tables to be
  4879.      deleted through an alias. This is fixed as of MySQL 4.1.
  4880.  
  4881.    * You cannot mix `UNION ALL' and `UNION DISTINCT' in the same query.
  4882.      If you use `ALL' for one `UNION', it is used for all of them.
  4883.      This is fixed as of MySQL 4.1.2. The rules for mixed `UNION' types
  4884.      are given in *Note `UNION': UNION.
  4885.  
  4886.    * `FLUSH TABLES WITH READ LOCK' does not block `CREATE TABLE', which
  4887.      may cause a problem with the binary log position when doing a full
  4888.      backup of tables and the binary log.
  4889.  
  4890. Open Bugs and Design Deficiencies in MySQL
  4891. ..........................................
  4892.  
  4893. The following problems are known and fixing them is a high priority:
  4894.  
  4895.    * Even if you are using `lower_case_table_names=2' (which enables
  4896.      MySQL to remember the used case for databases and table names)
  4897.      MySQL will not on case insensitive systems remember the used case
  4898.      for database names for the function `DATABASE()' or in various
  4899.      logs.
  4900.  
  4901.    * Dropping a `FOREIGN KEY' constraint doesn't work in replication
  4902.      because the constraint may have another name on the slave.
  4903.  
  4904.    * `REPLACE' (and `LOAD DATA' with the `REPLACE' option) does not
  4905.      trigger `ON DELETE CASCADE'.
  4906.  
  4907.    * `DISTINCT' with `ORDER BY' doesn't work inside `GROUP_CONCAT()' if
  4908.      you don't use all and only those columns that are in the
  4909.      `DISTINCT' list.
  4910.  
  4911.    * If one user has a long-running transaction and another user drops a
  4912.      table that is updated in the transaction, there is small chance
  4913.      that the binary log may contain the `DROP TABLE' command before
  4914.      the table is used in the transaction itself.  We plan to fix this
  4915.      in 5.0 by having the `DROP TABLE' wait until the table is not used
  4916.      in any transaction.
  4917.  
  4918.    * When inserting a big integer value (between 2^63 and 2^64-1) into a
  4919.      decimal/string column, it is inserted as a negative value because
  4920.      the number is evaluated in a signed integer context. We plan to
  4921.      fix this in MySQL 4.1.
  4922.  
  4923.      `FLUSH TABLES WITH READ LOCK' does not block `COMMIT' if the server
  4924.      is running without binary logging, which may cause a problem (of
  4925.      consistency between tables) when doing a full backup.
  4926.  
  4927.    * `ANALYZE TABLE' on a `BDB' table may in some cases make the table
  4928.      unusable until you restart `mysqld'.  If this happens, you will
  4929.      see errors of the following form in the MySQL error file:
  4930.  
  4931.           001207 22:07:56  bdb:  log_flush: LSN past current end-of-log
  4932.  
  4933.    * MySQL accepts parentheses in the `FROM' clause of a `SELECT'
  4934.      statement, but silently ignores them.  The reason for not giving
  4935.      an error is that many clients that automatically generate queries
  4936.      add parentheses in the `FROM' clause even where they are not
  4937.      needed.
  4938.  
  4939.    * Concatenating many `RIGHT JOINS' or combining `LEFT' and `RIGHT'
  4940.      join in the same query may not give a correct answer because MySQL
  4941.      only generates `NULL' rows for the table preceding a `LEFT' or
  4942.      before a `RIGHT' join.  This will be fixed in 5.0 at the same time
  4943.      we add support for parentheses in the `FROM' clause.
  4944.  
  4945.    * Don't execute `ALTER TABLE' on a `BDB' table on which you are
  4946.      running multiple-statement transactions until all those
  4947.      transactions complete.  (The transaction will probably be ignored.)
  4948.  
  4949.    * `ANALYZE TABLE', `OPTIMIZE TABLE', and `REPAIR TABLE' may cause
  4950.      problems on tables for which you are using `INSERT DELAYED'.
  4951.  
  4952.    * Doing a `LOCK TABLE ...' and `FLUSH TABLES ...' doesn't guarantee
  4953.      that there isn't a half-finished transaction in progress on the
  4954.      table.
  4955.  
  4956.    * `BDB' tables are a bit slow to open. If you have many `BDB' tables
  4957.      in a database, it will take a long time to use the `mysql' client
  4958.      on the database if you are not using the `-A' option or if you are
  4959.      using `rehash'. This is especially notable when you have a large
  4960.      table cache.
  4961.  
  4962.    * Replication uses query-level logging: The master writes the
  4963.      executed queries to the binary log. This is a very fast, compact,
  4964.      and efficient logging method that works perfectly in most cases.
  4965.      Although we have never heard of it actually occurring, it is
  4966.      theoretically possible for the data on the master and slave to
  4967.      become different if a query is designed in such a way that the
  4968.      data modification is non-deterministic; that is, left to the will
  4969.      of the query optimizer. (That generally is not a good practice
  4970.      anyway, even outside of replication!)  For example:
  4971.  
  4972.         - `CREATE ... SELECT' or `INSERT ... SELECT'  statements that
  4973.           insert zero or `NULL' values into an `AUTO_INCREMENT' column.
  4974.  
  4975.         - `DELETE' if you are deleting rows from a table that has
  4976.           foreign keys with `ON DELETE CASCADE' properties.
  4977.  
  4978.         - `REPLACE ... SELECT', `INSERT IGNORE ... SELECT' if you have
  4979.           duplicate key values in the inserted data.
  4980.      *If and only if all these queries have no `ORDER BY' clause
  4981.      guaranteeing a deterministic order*.
  4982.  
  4983.      For example, for `INSERT ... SELECT' with no `ORDER BY', the
  4984.      `SELECT' may return rows in a different order (which will result
  4985.      in a row having different ranks, hence getting a different number
  4986.      in the `AUTO_INCREMENT' column), depending on the choices made by
  4987.      the optimizers on the master and slave. A query will be optimized
  4988.      differently on the master and slave only if:
  4989.  
  4990.         - The files used by the two queries are not exactly the same;
  4991.           for example, `OPTIMIZE TABLE' was run on the master tables
  4992.           and not on the slave tables. (To fix this, `OPTIMIZE TABLE',
  4993.           `ANALYZE TABLE', and `REPAIR TABLE' are written to the binary
  4994.           log as of MySQL 4.1.1).
  4995.  
  4996.         - The table is stored using a different storage engine on the
  4997.           master than on the slave. (It is possible to use different
  4998.           storage engines on the master and slave. For example, you can
  4999.           use `InnoDB' on the master, but `MyISAM' on the slave if the
  5000.           slave has less available disk space.)
  5001.  
  5002.         - MySQL buffer sizes (`key_buffer_size', and so on) are
  5003.           different on the master and slave.
  5004.  
  5005.         - The master and slave run different MySQL versions, and the
  5006.           optimizer code differs between these versions.
  5007.  
  5008.      This problem may also affect database restoration using
  5009.      `mysqlbinlog|mysql'.
  5010.  
  5011.      The easiest way to avoid this problem in all cases is to add an
  5012.      `ORDER BY' clause to such non-deterministic queries to ensure that
  5013.      the rows are always stored or modified in the same order.  In
  5014.      future MySQL versions, we will automatically add an `ORDER BY'
  5015.      clause when needed.
  5016.  
  5017.  
  5018. The following problems are known and will be fixed in due time:
  5019.  
  5020.    * Log filenames are based on the server hostname (if you don't
  5021.      specify a filename with the startup option). For now you have to
  5022.      use options like `--log-bin=OLD_HOST_NAME-bin' if you change your
  5023.      hostname to something else. Another option is to just rename the
  5024.      old files to reflect your hostname change. *Note Server options::.
  5025.  
  5026.    * `mysqlbinlog' will not delete temporary files left after a `LOAD
  5027.      DATA INFILE' command. *Note `mysqlbinlog': mysqlbinlog.
  5028.  
  5029.    * `RENAME' doesn't work with `TEMPORARY' tables or tables used in a
  5030.      `MERGE' table.
  5031.  
  5032.    * When using the `RPAD()' function in a query that has to be
  5033.      resolved by using a temporary table, all resulting strings will
  5034.      have rightmost spaces removed. This is an example of such a query:
  5035.  
  5036.           SELECT RPAD(t1.column1, 50, ' ') AS f2, RPAD(t2.column2, 50, ' ') AS f1
  5037.           FROM table1 as t1 LEFT JOIN table2 AS t2 ON t1.record=t2.joinID
  5038.           ORDER BY t2.record;
  5039.  
  5040.      The final result of this bug is that you will not be able to get
  5041.      spaces on the right side of the resulting values. The problem also
  5042.      occurs for any other string function that adds spaces to the right.
  5043.  
  5044.      The reason for this is due to the fact that `HEAP' tables, which
  5045.      are used first for temporary tables, are not capable of handling
  5046.      `VARCHAR' columns.
  5047.  
  5048.      This behavior exists in all versions of MySQL.  It will be fixed
  5049.      in one of the 4.1 series releases.
  5050.  
  5051.    * Due to the way table definition files are stored, you cannot use
  5052.      character 255 (`CHAR(255)') in table names, column names, or
  5053.      enumerations.  This is scheduled to be fixed in version 5.1 when
  5054.      we have new table definition format files.
  5055.  
  5056.    * When using `SET CHARACTER SET', you can't use translated
  5057.      characters in database, table, and column names.
  5058.  
  5059.    * You can't use `_' or `%' with `ESCAPE' in `LIKE ... ESCAPE'.
  5060.  
  5061.    * If you have a `DECIMAL' column in which the same number is stored
  5062.      in different formats (for example, `+01.00', `1.00', `01.00'),
  5063.      `GROUP BY' may regard each value as a different value.
  5064.  
  5065.    * You cannot build the server in another directory when using
  5066.      MIT-pthreads. Because this requires changes to MIT-pthreads, we
  5067.      are not likely to fix this. *Note MIT-pthreads::.
  5068.  
  5069.    * `BLOB' and `TEXT'values can't "reliably" be used in `GROUP BY' or
  5070.      `ORDER BY' or `DISTINCT'. Only the first `max_sort_length' bytes
  5071.      are used when comparing `BLOB' values in these cases.  The default
  5072.      value of `max_sort_length' value is 1024. It can be changed at
  5073.      server startup time.  As of MySQL 4.0.3, it can also be changed at
  5074.      runtime. For older versions, a workaround for most cases is to use
  5075.      a substring.  For example:
  5076.  
  5077.           SELECT DISTINCT LEFT(BLOB_COL,2048) FROM TBL_NAME;
  5078.  
  5079.    * Numeric calculations are done with `BIGINT' or `DOUBLE' (both are
  5080.      normally 64 bits long). Which precision you get depends on the
  5081.      function.  The general rule is that bit functions are done with
  5082.      `BIGINT' precision, `IF' and `ELT()' with `BIGINT' or `DOUBLE'
  5083.      precision, and the rest with `DOUBLE' precision.  You should try to
  5084.      avoid using unsigned long long values if they resolve to be bigger
  5085.      than 63 bits (9223372036854775807) for anything other than bit
  5086.      fields.  MySQL Server 4.0 has better `BIGINT' handling than 3.23.
  5087.  
  5088.    * All string columns, except `BLOB' and `TEXT' columns, automatically
  5089.      have all trailing spaces removed when retrieved. For `CHAR' types,
  5090.      this is okay. The bug is that in MySQL Server, `VARCHAR' columns
  5091.      are treated the same way.
  5092.  
  5093.    * You can have only up to 255 `ENUM' and `SET' columns in one table.
  5094.  
  5095.    * In `MIN()', `MAX()', and other aggregate functions, MySQL
  5096.      currently compares `ENUM' and `SET' columns by their string value
  5097.      rather than by the string's relative position in the set.
  5098.  
  5099.    * `mysqld_safe' redirects all messages from `mysqld' to the `mysqld'
  5100.      log.  One problem with this is that if you execute `mysqladmin
  5101.      refresh' to close and reopen the log, `stdout' and `stderr' are
  5102.      still redirected to the old log.  If you use `--log' extensively,
  5103.      you should edit `mysqld_safe' to log to `HOST_NAME.err' instead of
  5104.      `HOST_NAME.log' so that you can easily reclaim the space for the
  5105.      old log by deleting the old one and executing `mysqladmin refresh'.
  5106.  
  5107.    * In the `UPDATE' statement, columns are updated from left to right.
  5108.      If you refer to an updated column, you get the updated value
  5109.      instead of the original value. For example, the following
  5110.      statement increments `KEY' by `2', not `1':
  5111.  
  5112.           mysql> UPDATE TBL_NAME SET KEY=KEY+1,KEY=KEY+1;
  5113.  
  5114.    * You can refer to multiple temporary tables in the same query, but
  5115.      you cannot refer to any given temporary table more than once.  For
  5116.      example, the following doesn't work:
  5117.  
  5118.           mysql> SELECT * FROM temp_table, temp_table AS t2;
  5119.           ERROR 1137: Can't reopen table: 'temp_table'
  5120.  
  5121.    * The optimizer may handle `DISTINCT' differently when you are using
  5122.      "hidden" columns in a join than when you are not.  In a join,
  5123.      hidden columns are counted as part of the result (even if they are
  5124.      not shown), whereas in normal queries, hidden columns don't
  5125.      participate in the `DISTINCT' comparison.  We will probably change
  5126.      this in the future to never compare the hidden columns when
  5127.      executing `DISTINCT'.
  5128.  
  5129.      An example of this is:
  5130.  
  5131.           SELECT DISTINCT mp3id FROM band_downloads
  5132.                  WHERE userid = 9 ORDER BY id DESC;
  5133.  
  5134.      and
  5135.  
  5136.           SELECT DISTINCT band_downloads.mp3id
  5137.                  FROM band_downloads,band_mp3
  5138.                  WHERE band_downloads.userid = 9
  5139.                  AND band_mp3.id = band_downloads.mp3id
  5140.                  ORDER BY band_downloads.id DESC;
  5141.  
  5142.      In the second case, you might in MySQL Server 3.23.x get two
  5143.      identical rows in the result set (because the values in the hidden
  5144.      `id' column may differ).
  5145.  
  5146.      Note that this happens only for queries where you don't have the
  5147.      `ORDER BY' columns in the result.
  5148.  
  5149.    * Because MySQL Server allows you to work with table types that don't
  5150.      support transactions, and thus can't roll back data, some things
  5151.      behave a little differently in MySQL Server than in other SQL
  5152.      servers.  This is just to ensure that MySQL Server never needs to
  5153.      do a rollback for an SQL statement.  This may be a little awkward
  5154.      at times because column values must be checked in the application,
  5155.      but this will actually give you a nice speed increase because it
  5156.      allows MySQL Server to do some optimizations that otherwise would
  5157.      be very hard to do.
  5158.  
  5159.      If you set a column to an incorrect value, MySQL Server will,
  5160.      instead of doing a rollback, store the "best possible value" in
  5161.      the column. For information about how this occurs, see *Note
  5162.      Constraints::.
  5163.  
  5164.    * If you execute a `PROCEDURE' on a query that returns an empty set,
  5165.      in some cases the `PROCEDURE' will not transform the columns.
  5166.  
  5167.    * Creation of a table of type `MERGE' doesn't check whether the
  5168.      underlying tables are of compatible types.
  5169.  
  5170.    * If you use `ALTER TABLE' first to add a `UNIQUE' index to a table
  5171.      used in a `MERGE' table and then to add a normal index on the
  5172.      `MERGE' table, the key order will be different for the tables if
  5173.      there was an old key that was not unique in the table. This is
  5174.      because `ALTER TABLE' puts `UNIQUE' indexes before normal indexes
  5175.      to be able to detect duplicate keys as early as possible.
  5176.  
  5177. The following are known bugs in earlier versions of MySQL:
  5178.  
  5179.    * In the following case you can get a core dump:
  5180.  
  5181.         - Delayed insert handler has pending inserts to a table.
  5182.  
  5183.         - `LOCK TABLE' with `WRITE'.
  5184.  
  5185.         - `FLUSH TABLES'.
  5186.  
  5187.    * Before MySQL Server 3.23.2, an `UPDATE' that updated a key with a
  5188.      `WHERE' on the same key may have failed because the key was used to
  5189.      search for records and the same row may have been found multiple
  5190.      times:
  5191.  
  5192.           UPDATE TBL_NAME SET KEY=KEY+1 WHERE KEY > 100;
  5193.  
  5194.      A workaround is to use:
  5195.  
  5196.           UPDATE TBL_NAME SET KEY=KEY+1 WHERE KEY+0 > 100;
  5197.  
  5198.      This will work because MySQL Server will not use an index on
  5199.      expressions in the `WHERE' clause.
  5200.  
  5201.    * Before MySQL Server 3.23, all numeric types were treated as
  5202.      fixed-point fields. That means that you had to specify how many
  5203.      decimals a floating-point field should have. All results were
  5204.      returned with the correct number of decimals.
  5205.  
  5206. For information about platform-specific bugs, see the installation and
  5207. porting instructions in *Note Operating System Specific Notes:: and
  5208. *Note Porting::.
  5209.  
  5210. Installing MySQL
  5211. ****************
  5212.  
  5213. This chapter describes how to obtain and install MySQL:
  5214.  
  5215.   1. *Determine whether your platform is supported.*  Please note that
  5216.      not all supported systems are equally good for running MySQL on
  5217.      them.  On some it is much more robust and efficient than others.
  5218.      See *Note Which OS:: for details.
  5219.  
  5220.   2. *Choose which distribution to install.*  Several versions of MySQL
  5221.      are available, and most are available in several distribution
  5222.      formats.  You can choose from pre-packaged distributions
  5223.      containing binary (precompiled) programs or source code.  When in
  5224.      doubt, use a binary distribution.  We also provide public access
  5225.      to our current source tree for those who want to see our most
  5226.      recent developments and help us test new code.  To determine which
  5227.      version and type of distribution you should use, see *Note Which
  5228.      version::.
  5229.  
  5230.   3. *Download the distribution that you want to install.* For a list
  5231.      of sites from which you can obtain MySQL, see *Note Getting MySQL:
  5232.      Getting MySQL.  You can verify the integrity of the distribution
  5233.      using the instructions in *Note Verifying Package Integrity::.
  5234.  
  5235.   4. *Install the distribution.*  To install MySQL from a binary
  5236.      distribution, use the instructions in *Note Quick Standard
  5237.      Installation::.  To install MySQL from a source distribution or
  5238.      from the current development source tree, use the instructions in
  5239.      *Note Installing source::.
  5240.  
  5241.      *Note*: If you plan to upgrade an existing version of MySQL to a
  5242.      newer version rather than installing MySQL for the first time, see
  5243.      *Note Upgrade:: for information about upgrade procedures and about
  5244.      issues that you should consider before upgrading.
  5245.  
  5246.      If you encounter installation difficulties, see *Note Operating
  5247.      System Specific Notes:: for information on solving problems for
  5248.      particular platforms.
  5249.  
  5250.   5. *Perform any necessary post-installation setup.* After installing
  5251.      MySQL, read *Note Post-installation::.  This section contains
  5252.      important information about making sure the MySQL server is
  5253.      working properly. It also describes how to secure the initial
  5254.      MySQL user accounts, _which have no passwords_ until you assign
  5255.      passwords.  The section applies whether you install MySQL using a
  5256.      binary or source distribution.
  5257.  
  5258.   6. If you want to run the MySQL benchmark scripts, Perl support for
  5259.      MySQL must be available.  *Note Perl support::.
  5260.  
  5261.  
  5262. General Installation Issues
  5263. ===========================
  5264.  
  5265. Before installing MySQL, you should do the following:
  5266.  
  5267.   1. Determine whether or not MySQL runs on your platform.
  5268.  
  5269.   2. Choose a distribution to install.
  5270.  
  5271.   3. Download the distribution and verify its integrity.
  5272.  
  5273.  
  5274. This section contains the information necessary to carry out these
  5275. steps.  After doing so, you can use the instructions in later sections
  5276. of the chapter to install the distribution that you choose.
  5277.  
  5278. Operating Systems Supported by MySQL
  5279. ------------------------------------
  5280.  
  5281. This section lists the operating systems on which you can expect to be
  5282. able to run MySQL.
  5283.  
  5284. We use GNU Autoconf, so it is possible to port MySQL to all modern
  5285. systems that have a C++ compiler and a working implementation of POSIX
  5286. threads.  (Thread support is needed for the server. To compile only the
  5287. client code, the only requirement is a C++ compiler.) We use and
  5288. develop the software ourselves primarily on Linux (SuSE and Red Hat),
  5289. FreeBSD, and Sun Solaris (Versions 8 and 9).
  5290.  
  5291. MySQL has been reported to compile successfully on the following
  5292. combinations of operating system and thread package.  Note that for many
  5293. operating systems, native thread support works only in the latest
  5294. versions.
  5295.  
  5296.    * AIX 4.x, 5.x with native threads.  *Note IBM-AIX::.
  5297.  
  5298.    * Amiga.
  5299.  
  5300.    * BSDI 2.x with the MIT-pthreads package.  *Note BSDI::.
  5301.  
  5302.    * BSDI 3.0, 3.1 and 4.x with native threads.  *Note BSDI::.
  5303.  
  5304.    * Digital Unix 4.x with native threads.  *Note Alpha-DEC-UNIX::.
  5305.  
  5306.    * FreeBSD 2.x with the MIT-pthreads package.  *Note FreeBSD::.
  5307.  
  5308.    * FreeBSD 3.x and 4.x with native threads.  *Note FreeBSD::.
  5309.  
  5310.    * FreeBSD 4.x with LinuxThreads.  *Note FreeBSD::.
  5311.  
  5312.    * HP-UX 10.20 with the DCE threads or the MIT-pthreads package.
  5313.      *Note HP-UX 10.20::.
  5314.  
  5315.    * HP-UX 11.x with the native threads.  *Note HP-UX 11.x::.
  5316.  
  5317.    * Linux 2.0+ with LinuxThreads 0.7.1+ or `glibc' 2.0.7+ for various
  5318.      CPU architectures.  *Note Linux::.
  5319.  
  5320.    * Mac OS X.  *Note Mac OS X::.
  5321.  
  5322.    * NetBSD 1.3/1.4 Intel and NetBSD 1.3 Alpha (requires GNU make).
  5323.      *Note NetBSD::.
  5324.  
  5325.    * Novell NetWare 6.0.  *Note NetWare installation::.
  5326.  
  5327.    * OpenBSD > 2.5 with native threads. OpenBSD < 2.5 with the
  5328.      MIT-pthreads package.  *Note OpenBSD::.
  5329.  
  5330.    * OS/2 Warp 3, FixPack 29 and OS/2 Warp 4, FixPack 4.  *Note OS/2::.
  5331.  
  5332.    * SCO OpenServer with a recent port of the FSU Pthreads package.
  5333.      *Note SCO::.
  5334.  
  5335.    * SCO UnixWare 7.1.x.  *Note SCO UnixWare::.
  5336.  
  5337.    * SGI Irix 6.x with native threads.  *Note SGI-Irix::.
  5338.  
  5339.    * Solaris 2.5 and above with native threads on SPARC and x86.  *Note
  5340.      Solaris::.
  5341.  
  5342.    * SunOS 4.x with the MIT-pthreads package.  *Note Solaris::.
  5343.  
  5344.    * Tru64 Unix.  *Note Alpha-DEC-UNIX::.
  5345.  
  5346.    * Windows 9x, Me, NT, 2000, and XP.  *Note Windows installation::.
  5347.  
  5348. Not all platforms are equally well-suited for running MySQL. How well a
  5349. certain platform is suited for a high-load mission-critical MySQL
  5350. server is determined by the following factors:
  5351.  
  5352.    * General stability of the thread library. A platform may have an
  5353.      excellent reputation otherwise, but MySQL will be only as stable
  5354.      as the thread library if that library is unstable in the code that
  5355.      is called by MySQL, even if everything else is perfect.
  5356.  
  5357.    * The capability of the kernel and the thread library to take
  5358.      advantage of symmetric multi-processor (SMP) systems. In other
  5359.      words, when a process creates a thread, it should be possible for
  5360.      that thread to run on a different CPU than the original process.
  5361.  
  5362.    * The capability of the kernel and the thread library to run many
  5363.      threads that acquire and release a mutex over a short critical
  5364.      region frequently without excessive context switches. If the
  5365.      implementation of `pthread_mutex_lock()' is too anxious to yield
  5366.      CPU time, this will hurt MySQL tremendously. If this issue is not
  5367.      taken care of, adding extra CPUs will actually make MySQL slower.
  5368.  
  5369.    * General filesystem stability and performance.
  5370.  
  5371.    * If your tables are big, the ability of the filesystem to deal with
  5372.      large files at all and to deal with them efficiently.
  5373.  
  5374.    * Our level of expertise here at MySQL AB with the platform. If we
  5375.      know a platform well, we enable platform-specific optimizations
  5376.      and fixes at compile time. We can also provide advice on
  5377.      configuring your system optimally for MySQL.
  5378.  
  5379.    * The amount of testing we have done internally for similar
  5380.      configurations.
  5381.  
  5382.    * The number of users that have successfully run MySQL on the
  5383.      platform in similar configurations. If this number is high, the
  5384.      chances of encountering platform-specific surprises are much
  5385.      smaller.
  5386.  
  5387. Based on the preceding criteria, the best platforms for running MySQL
  5388. at this point are x86 with SuSE Linux using a 2.4 kernel, and ReiserFS
  5389. (or any similar Linux distribution) and SPARC with Solaris (2.7-9).
  5390. FreeBSD comes third, but we really hope it will join the top club once
  5391. the thread library is improved. We also hope that at some point we will
  5392. be able to include into the top category all other platforms on which
  5393. MySQL currently compiles and runs okay, but not quite with the same
  5394. level of stability and performance.  This will require some effort on
  5395. our part in cooperation with the developers of the operating system and
  5396. library components that MySQL depends on. If you are interested in
  5397. improving one of those components, are in a position to influence its
  5398. development, and need more detailed instructions on what MySQL needs to
  5399. run better, send an email message to the MySQL `internals' mailing list.
  5400. *Note Mailing-list::.
  5401.  
  5402. Please note that the purpose of the preceding comparison is not to say
  5403. that one operating system is better or worse than another in general.
  5404. We are talking only about choosing an OS for the specific purpose of
  5405. running MySQL.  With this in mind, the result of this comparison would
  5406. be different if we considered more factors. In some cases, the reason
  5407. one OS is better than the other could simply be that we have been able
  5408. to put more effort into testing and optimizing for a particular
  5409. platform.  We are just stating our observations to help you decide
  5410. which platform to use for running MySQL.
  5411.  
  5412. Choosing Which MySQL Distribution to Install
  5413. --------------------------------------------
  5414.  
  5415. When preparing to install MySQL, you should decide which version to
  5416. use.  MySQL development occurs in several release series, and you can
  5417. pick the one that best fits your needs.  After deciding which version
  5418. to install, you can choose a distribution format.  Releases are
  5419. available in binary or source format.
  5420.  
  5421. Choosing Which Version of MySQL to Install
  5422. ..........................................
  5423.  
  5424. The first decision to make is whether you want to use a production
  5425. (stable) release or a development release.  In the MySQL development
  5426. process, multiple release series co-exist, each at a different stage of
  5427. maturity:
  5428.  
  5429.    * MySQL 5.0 is the newest development release series and is under
  5430.      very active development for new features. Alpha releases have been
  5431.      issued to allow more widespread testing.
  5432.  
  5433.    * MySQL 4.1 is in gamma status, soon moving to production status.
  5434.  
  5435.    * MySQL 4.0 is the current stable (production-quality) release
  5436.      series.  New releases are issued for bugfixes. No new features are
  5437.      added that could diminish the code stability.
  5438.  
  5439.    * MySQL 3.23 is the old stable (production-quality) release series.
  5440.      This series is retired, so new releases are issued only to fix
  5441.      critical bugs.
  5442.  
  5443.  
  5444. We don't believe in a complete freeze, as this also leaves out bugfixes
  5445. and things that "must be done."  "Somewhat frozen" means that we may add
  5446. small things that "almost surely will not affect anything that's already
  5447. working." Naturally, relevant bugfixes from an earlier series propagate
  5448. to later series.
  5449.  
  5450. Normally, if you are beginning to use MySQL for the first time or trying
  5451. to port it to some system for which there is no binary distribution, we
  5452. recommend going with the production release series. Currently this is
  5453. MySQL 4.0.  All MySQL releases, even those from development series, are
  5454. checked with the MySQL benchmarks and an extensive test suite before
  5455. being issued.
  5456.  
  5457. If you are running an old system and want to upgrade, but don't want to
  5458. take the chance of having a non-seamless upgrade, you should upgrade to
  5459. the latest version in the same release series you are using (where only
  5460. the last part of the version number is newer than yours).  We have tried
  5461. to fix only fatal bugs and make small, relatively safe changes to that
  5462. version.
  5463.  
  5464. If you want to use new features not present in the production release
  5465. series, you can use a version from a development series. Note that
  5466. development releases are not as stable as production releases.
  5467.  
  5468. If you want to use the very latest sources containing all current
  5469. patches and bugfixes, you can use one of our BitKeeper repositories.
  5470. These are not "releases" as such, but are available as previews of the
  5471. code on which future releases will be based.
  5472.  
  5473. The MySQL naming scheme uses release names that consist of three
  5474. numbers and a suffix; for example, `mysql-4.1.2-alpha'.  The numbers
  5475. within the release name are interpreted like this:
  5476.  
  5477.    * The first number (`4') is the major version and also describes the
  5478.      file format.  All Version 4 releases have the same file format.
  5479.  
  5480.    * The second number (`1') is the release level.  Taken together, the
  5481.      major version and release level constitute the release series
  5482.      number.
  5483.  
  5484.    * The third number (`2') is the version number within the release
  5485.      series.  This is incremented for each new release.  Usually you
  5486.      want the latest version for the series you have chosen.
  5487.  
  5488.  
  5489. For each minor update, the last number in the version string is
  5490. incremented.  When there are major new features or minor
  5491. incompatibilities with previous versions, the second number in the
  5492. version string is incremented.  When the file format changes, the first
  5493. number is increased.
  5494.  
  5495. Release names also include a suffix to indicates the stability level of
  5496. the release.  Releases within a series progress through a set of
  5497. suffixes to indicate how the stability level improves.  The possible
  5498. suffixes are:
  5499.  
  5500.    * `alpha' indicates that the release contains some large section of
  5501.      new code that hasn't been 100% tested.  Known bugs (usually there
  5502.      are none) should be documented in the News section.  *Note News::.
  5503.      There are also new commands and extensions in most alpha
  5504.      releases.  Active development that may involve major code changes
  5505.      can occur in an alpha release, but everything will be tested
  5506.      before issuing a release.  For this reason, there should be no
  5507.      known bugs in any MySQL release.
  5508.  
  5509.    * `beta' means that all new code has been tested.  No major new
  5510.      features that could cause corruption in old code are added.  There
  5511.      should be no known bugs.  A version changes from alpha to beta
  5512.      when there haven't been any reported fatal bugs within an alpha
  5513.      version for at least a month and we have no plans to add any
  5514.      features that could make any old command unreliable.
  5515.  
  5516.    * `gamma' is a beta that has been around a while and seems to work
  5517.      fine.  Only minor fixes are added.  This is what many other
  5518.      companies call a release.
  5519.  
  5520.    * If there is no suffix, it means that the version has been run for a
  5521.      while at many different sites with no reports of bugs other than
  5522.      platform-specific bugs.  Only critical bugfixes are applied to the
  5523.      release. This is what we call a production (stable) release.
  5524.  
  5525. MySQL uses a naming scheme that is slightly different from most other
  5526. products.  In general, it's relatively safe to use any version that has
  5527. been out for a couple of weeks without being replaced with a new
  5528. version within the release series.
  5529.  
  5530. All releases of MySQL are run through our standard tests and benchmarks
  5531. to ensure that they are relatively safe to use.  Because the standard
  5532. tests are extended over time to check for all previously found bugs,
  5533. the test suite keeps getting better.
  5534.  
  5535. All releases have been tested at least with:
  5536.  
  5537. An internal test suite
  5538.      The `mysql-test' directory contains an extensive set of test cases.
  5539.      We run these tests for virtually every server binary.  See *Note
  5540.      MySQL test suite:: for more information about this test suite.
  5541.  
  5542. The MySQL benchmark suite
  5543.      This suite runs a range of common queries.  It is also a test to
  5544.      see whether the latest batch of optimizations actually made the
  5545.      code faster.  *Note MySQL Benchmarks::.
  5546.  
  5547. The `crash-me' test
  5548.      This test tries to determine what features the database supports
  5549.      and what its capabilities and limitations are.  *Note MySQL
  5550.      Benchmarks::.
  5551.  
  5552. Another test is that we use the newest MySQL version in our internal
  5553. production environment, on at least one machine.  We have more than
  5554. 100GB of data to work with.
  5555.  
  5556. Choosing a Distribution Format
  5557. ..............................
  5558.  
  5559. After choosing which version of MySQL to install, you should decide
  5560. whether to use a binary distribution or a source distribution.  In most
  5561. cases, you should probably use a binary distribution, if one exists for
  5562. your platform. Binary distributions are available in native format for
  5563. many platforms, such as RPM files for Linux or DMG package installers
  5564. for Mac OS X. Distributions also are available as Zip archives or
  5565. compressed `tar' files.
  5566.  
  5567. Reasons to choose a binary distribution include the following:
  5568.  
  5569.    * Binary distributions generally are easier to install than source
  5570.      distributions.
  5571.  
  5572.    * To satisfy different user requirements, we provide two different
  5573.      binary versions: one compiled with the non-transactional storage
  5574.      engines (a small, fast binary), and one configured with the most
  5575.      important extended options like transaction-safe tables.  Both
  5576.      versions are compiled from the same source distribution.  All
  5577.      native MySQL clients can connect to servers from either MySQL
  5578.      version.
  5579.  
  5580.      The extended MySQL binary distribution is marked with the `-max'
  5581.      suffix and is configured with the same options as `mysqld-max'.
  5582.      *Note `mysqld-max': mysqld-max.
  5583.  
  5584.      If you want to use the `MySQL-Max' RPM, you must first install the
  5585.      standard `MySQL-server' RPM.
  5586.  
  5587.  
  5588. Under some circumstances, you probably will be better off installing
  5589. MySQL from a source distribution:
  5590.  
  5591.    * You want to install MySQL at some explicit location.  The standard
  5592.      binary distributions are "ready to run" at any place, but you may
  5593.      want to have even more flexibility to place MySQL components where
  5594.      you want.
  5595.  
  5596.    * You want to configure `mysqld' with some extra features that are
  5597.      not included in the standard binary distributions.  Here is a list
  5598.      of the most common extra options that you may want to use:
  5599.  
  5600.         * `--with-innodb' (default for MySQL 4.0 and up)
  5601.  
  5602.         * `--with-berkeley-db' (not available on all platforms)
  5603.  
  5604.         * `--with-raid'
  5605.  
  5606.         * `--with-libwrap'
  5607.  
  5608.         * `--with-named-z-libs' (this is done for some of the binaries)
  5609.  
  5610.         * `--with-debug[=FULL]'
  5611.  
  5612.    * You want to configure `mysqld' without some features that are
  5613.      included in the standard binary distributions. For example,
  5614.      distributions normally are compiled with support for all character
  5615.      sets. If you want a smaller MySQL server, you can recompile it
  5616.      with support for only the character sets you need.
  5617.  
  5618.    * You have a special compiler (such as `pgcc') or want to use
  5619.      compiler options that are better optimized for your processor.
  5620.      Binary distributions are compiled with options that should work on
  5621.      a variety of processors from the same processor family.
  5622.  
  5623.    * You want to use the latest sources from one of the BitKeeper
  5624.      repositories to have access to all current bugfixes. For example,
  5625.      if you have found a bug and reported it to the MySQL development
  5626.      team, the bugfix will be committed to the source repository and you
  5627.      can access it there.  The bugfix will not appear in a release until
  5628.      a release actually is issued.
  5629.  
  5630.    * You want to read (or modify) the C and C++ code that makes up
  5631.      MySQL. For this purpose, you should get a source distribution,
  5632.      because the source code is always the ultimate manual.
  5633.  
  5634.    * Source distributions contain more tests and examples than binary
  5635.      distributions.
  5636.  
  5637.  
  5638. How and When Updates Are Released
  5639. .................................
  5640.  
  5641. MySQL is evolving quite rapidly here at MySQL AB and we want to share
  5642. new developments with other MySQL users.  We try to make a release when
  5643. we have very useful features that others seem to have a need for.
  5644.  
  5645. We also try to help out users who request features that are easy to
  5646. implement.  We take note of what our licensed users want to have, and
  5647. we especially take note of what our extended email-supported customers
  5648. want and try to help them out.
  5649.  
  5650. No one has to download a new release.  The News section will tell you if
  5651. the new release has something you really want.  *Note News::.
  5652.  
  5653. We use the following policy when updating MySQL:
  5654.  
  5655.    * Releases are issued within each series. For each release, the last
  5656.      number in the version is one more than the previous release within
  5657.      the same series.
  5658.  
  5659.    * Production (stable) releases are meant to appear about 1-2 times a
  5660.      year.  However, if small bugs are found, a release with only
  5661.      bugfixes will be issued.
  5662.  
  5663.    * Working releases/bugfixes to old releases are meant to appear about
  5664.      every 4-8 weeks.
  5665.  
  5666.    * Binary distributions for some platforms are made by us for major
  5667.      releases.  Other people may make binary distributions for other
  5668.      systems, but probably less frequently.
  5669.  
  5670.    * We make fixes available as soon as we have identified and corrected
  5671.      small or non-critical but annoying bugs. The fixes are available
  5672.      immediately from our public BitKeeper repositories, and will be
  5673.      included in the next release.
  5674.  
  5675.    * If by any chance a fatal bug is found in a release, we will make a
  5676.      new release as soon as possible.  (We would like other companies
  5677.      to do this, too!)
  5678.  
  5679. Release Philosophy--No Known Bugs in Releases
  5680. .............................................
  5681.  
  5682. We put a lot of time and effort into making our releases bug-free.  To
  5683. our knowledge, we have not released a single MySQL version with any
  5684. _known_ "fatal" repeatable bugs.  (A "fatal" bug is something that
  5685. crashes MySQL under normal usage, produces incorrect answers for normal
  5686. queries, or has a security problem.)
  5687.  
  5688. We have documented all open problems, bugs, and issues that are
  5689. dependent on design decisions.  *Note Bugs::.
  5690.  
  5691. Our aim is to fix everything that is fixable without risk of making a
  5692. stable MySQL version less stable. In certain cases, this means we can
  5693. fix an issue in the development versions, but not in the stable
  5694. (production) version. Naturally, we document such issues so that users
  5695. are aware of them.
  5696.  
  5697. Here is a description of how our build process works:
  5698.    * We monitor bugs from our customer support list, the bugs database
  5699.      at `http://bugs.mysql.com/', and the MySQL external mailing lists.
  5700.  
  5701.    * All reported bugs for live versions are entered into the bugs
  5702.      database.
  5703.  
  5704.    * When we fix a bug, we always try to make a test case for it and
  5705.      include it into our test system to ensure that the bug will never
  5706.      recur without being detected. (About 90% of all fixed bugs have a
  5707.      test case.)
  5708.  
  5709.    * We create test cases for all new features we add to MySQL.
  5710.  
  5711.    * Before we start to build a new MySQL release, we ensure that all
  5712.      reported repeatable bugs for the MySQL version (3.23.x, 4.0.x, etc)
  5713.      are fixed.  If something is impossible to fix (due to some internal
  5714.      design decision in MySQL), we document this in the manual.  *Note
  5715.      Bugs::.
  5716.  
  5717.    * We do a build on all platforms for which we support binaries (15+
  5718.      platforms) and run our test suite and benchmark suite on all of
  5719.      them.
  5720.  
  5721.    * We will not publish a binary for a platform for which the test or
  5722.      benchmark suite fails.  If the problem is due to a general error
  5723.      in the source, we fix it and do the build plus tests on all
  5724.      systems again from scratch.
  5725.  
  5726.    * The build and test process takes 2-3 days.  If we receive a report
  5727.      regarding a fatal bug during this process (for example, one that
  5728.      causes a core dump), we fix the problem and restart the build
  5729.      process.
  5730.  
  5731.    * After publishing the binaries on `http://dev.mysql.com/', we send
  5732.      out an announcement message to the `mysql' and `announce' mailing
  5733.      lists.  *Note Mailing-list::.  The announcement message contains a
  5734.      list of all changes to the release and any known problems with the
  5735.      release.  The Known Problems section in the release notes has been
  5736.      needed for only a handful of releases.
  5737.  
  5738.    * To quickly give our users access to the latest MySQL features, we
  5739.      do a new MySQL release every 4-8 weeks.  Source code snapshots are
  5740.      built daily and are available at
  5741.      `http://downloads.mysql.com/snapshots.php'.
  5742.  
  5743.    * If, despite our best efforts, we get any bug reports after the
  5744.      release is done that there was something critically wrong with the
  5745.      build on a specific platform, we will fix it at once and build a
  5746.      new `'a'' release for that platform. Thanks to our large user
  5747.      base, problems are found quickly.
  5748.  
  5749.    * Our track record for making good releases is quite good.  In the
  5750.      last 150 releases, we had to do a new build for fewer than 10
  5751.      releases. In three of these cases, the bug was a faulty `glibc'
  5752.      library on one of our build machines that took us a long time to
  5753.      track down.
  5754.  
  5755. MySQL Binaries Compiled by MySQL AB
  5756. ...................................
  5757.  
  5758. As a service of MySQL AB, we provide a set of binary distributions of
  5759. MySQL that are compiled on systems at our site or on systems where
  5760. supporters of MySQL kindly have given us access to their machines.
  5761.  
  5762. In addition to the binaries provided in platform-specific package
  5763. formats, we offer binary distributions for a number of platforms in the
  5764. form of compressed `tar' files (`.tar.gz' files).  *Note Quick Standard
  5765. Installation::.
  5766.  
  5767. For Windows distributions, see *Note Windows installation::.
  5768.  
  5769. These distributions are generated using the script
  5770. `Build-tools/Do-compile', which compiles the source code and creates
  5771. the binary `tar.gz' archive using `scripts/make_binary_distribution'.
  5772.  
  5773. These binaries are configured and built with the following compilers and
  5774. options. This information can also be obtained by looking at the
  5775. variables `COMP_ENV_INFO' and `CONFIGURE_LINE' inside the script
  5776. `bin/mysqlbug' of every binary `tar' file distribution.
  5777.  
  5778. The following binaries are built on MySQL AB development systems:
  5779.  
  5780. Linux 2.4.xx x86 with `gcc' 2.95.3:
  5781.      `CFLAGS="-O2 -mcpu=pentiumpro" CXX=gcc CXXFLAGS="-O2
  5782.      -mcpu=pentiumpro -felide-constructors" ./configure
  5783.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5784.      --enable-thread-safe-client --enable-local-infile
  5785.      --enable-assembler --disable-shared
  5786.      --with-client-ldflags=-all-static
  5787.      --with-mysqld-ldflags=-all-static'
  5788.  
  5789. Linux 2.4.x x86 with `icc' (Intel C++ Compiler 8.0):
  5790.      `CC=icc CXX=icc CFLAGS="-O3 -unroll2 -ip -mp -no-gcc -restrict"
  5791.      CXXFLAGS="-O3 -unroll2 -ip -mp -no-gcc -restrict" ./configure
  5792.      --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data
  5793.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5794.      --enable-thread-safe-client --enable-local-infile
  5795.      --enable-assembler --disable-shared
  5796.      --with-client-ldflags=-all-static
  5797.      --with-mysqld-ldflags=-all-static --with-embedded-server
  5798.      --with-innodb'
  5799.  
  5800. Linux 2.4.xx Intel Itanium 2 with `ecc' (Intel C++ Itanium Compiler 7.0):
  5801.      `CC=ecc CFLAGS="-O2 -tpp2 -ip -nolib_inline" CXX=ecc CXXFLAGS="-O2
  5802.      -tpp2 -ip -nolib_inline" ./configure --prefix=/usr/local/mysql
  5803.      --with-extra-charsets=complex --enable-thread-safe-client
  5804.      --enable-local-infile'
  5805.  
  5806. Linux 2.4.xx Intel Itanium with `ecc' (Intel C++ Itanium Compiler 7.0):
  5807.      `CC=ecc CFLAGS=-tpp1 CXX=ecc CXXFLAGS=-tpp1 ./configure
  5808.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5809.      --enable-thread-safe-client --enable-local-infile'
  5810.  
  5811. Linux 2.4.xx alpha with `ccc' (Compaq C V6.2-505 / Compaq C++ V6.3-006):
  5812.      `CC=ccc CFLAGS="-fast -arch generic" CXX=cxx CXXFLAGS="-fast -arch
  5813.      generic -noexceptions -nortti" ./configure
  5814.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5815.      --enable-thread-safe-client --enable-local-infile
  5816.      --with-mysqld-ldflags=-non_shared
  5817.      --with-client-ldflags=-non_shared --disable-shared'
  5818.  
  5819. Linux 2.x.xx ppc with `gcc' 2.95.4:
  5820.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5821.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5822.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5823.      --localstatedir=/usr/local/mysql/data
  5824.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5825.      --enable-thread-safe-client --enable-local-infile
  5826.      --disable-shared --with-embedded-server --with-innodb'
  5827.  
  5828. Linux 2.4.xx s390 with `gcc' 2.95.3:
  5829.      `CFLAGS="-O2" CXX=gcc CXXFLAGS="-O2 -felide-constructors"
  5830.      ./configure --prefix=/usr/local/mysql
  5831.      --with-extra-charsets=complex --enable-thread-safe-client
  5832.      --enable-local-infile --disable-shared
  5833.      --with-client-ldflags=-all-static
  5834.      --with-mysqld-ldflags=-all-static'
  5835.  
  5836. Linux 2.4.xx x86_64 (AMD64) with `gcc' 3.2.1:
  5837.      `CXX=gcc ./configure --prefix=/usr/local/mysql
  5838.      --with-extra-charsets=complex --enable-thread-safe-client
  5839.      --enable-local-infile  --disable-shared'
  5840.  
  5841. Sun Solaris 8 x86 with `gcc' 3.2.3:
  5842.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5843.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5844.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5845.      --localstatedir=/usr/local/mysql/data
  5846.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5847.      --enable-thread-safe-client --enable-local-infile
  5848.      --disable-shared --with-innodb'
  5849.  
  5850. Sun Solaris 8 SPARC with `gcc' 3.2:
  5851.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5852.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5853.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5854.      --with-extra-charsets=complex --enable-thread-safe-client
  5855.      --enable-local-infile --enable-assembler --with-named-z-libs=no
  5856.      --with-named-curses-libs=-lcurses --disable-shared'
  5857.  
  5858. Sun Solaris 8 SPARC 64-bit with `gcc' 3.2:
  5859.      `CC=gcc CFLAGS="-O3 -m64 -fno-omit-frame-pointer" CXX=gcc
  5860.      CXXFLAGS="-O3 -m64 -fno-omit-frame-pointer -felide-constructors
  5861.      -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql
  5862.      --with-extra-charsets=complex --enable-thread-safe-client
  5863.      --enable-local-infile --with-named-z-libs=no
  5864.      --with-named-curses-libs=-lcurses --disable-shared'
  5865.  
  5866. Sun Solaris 9 SPARC with `gcc' 2.95.3:
  5867.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5868.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5869.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5870.      --with-extra-charsets=complex --enable-thread-safe-client
  5871.      --enable-local-infile --enable-assembler
  5872.      --with-named-curses-libs=-lcurses --disable-shared'
  5873.  
  5874. Sun Solaris 9 SPARC with `cc-5.0' (Sun Forte 5.0):
  5875.      `CC=cc-5.0 CXX=CC ASFLAGS="-xarch=v9" CFLAGS="-Xa -xstrconst -mt
  5876.      -D_FORTEC_ -xarch=v9" CXXFLAGS="-noex -mt -D_FORTEC_ -xarch=v9"
  5877.      ./configure --prefix=/usr/local/mysql
  5878.      --with-extra-charsets=complex --enable-thread-safe-client
  5879.      --enable-local-infile --enable-assembler --with-named-z-libs=no
  5880.      --enable-thread-safe-client --disable-shared'
  5881.  
  5882. IBM AIX 4.3.2 ppc with `gcc' 3.2.3:
  5883.      `CFLAGS="-O2 -mcpu=powerpc -Wa,-many " CXX=gcc CXXFLAGS="-O2
  5884.      -mcpu=powerpc -Wa,-many  -felide-constructors -fno-exceptions
  5885.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5886.      --with-extra-charsets=complex --enable-thread-safe-client
  5887.      --enable-local-infile --with-named-z-libs=no --disable-shared'
  5888.  
  5889. IBM AIX 4.3.3 ppc with `xlC_r' (IBM Visual Age C/C++ 6.0):
  5890.      `CC=xlc_r CFLAGS="-ma -O2 -qstrict -qoptimize=2 -qmaxmem=8192"
  5891.      CXX=xlC_r CXXFLAGS ="-ma -O2 -qstrict -qoptimize=2 -qmaxmem=8192"
  5892.      ./configure --prefix=/usr/local/mysql
  5893.      --localstatedir=/usr/local/mysql/data
  5894.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5895.      --enable-thread-safe-client --enable-local-infile
  5896.      --with-named-z-libs=no --disable-shared --with-innodb'
  5897.  
  5898. IBM AIX 5.1.0 ppc with `gcc' 3.3:
  5899.      `CFLAGS="-O2 -mcpu=powerpc -Wa,-many" CXX=gcc CXXFLAGS="-O2
  5900.      -mcpu=powerpc -Wa,-many  -felide-constructors -fno-exceptions
  5901.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5902.      --with-extra-charsets=complex --enable-thread-safe-client
  5903.      --enable-local-infile --with-named-z-libs=no --disable-shared'
  5904.  
  5905. IBM AIX 5.2.0 ppc with `xlC_r' (IBM Visual Age C/C++ 6.0):
  5906.      `CC=xlc_r CFLAGS="-ma -O2 -qstrict -qoptimize=2 -qmaxmem=8192"
  5907.      CXX=xlC_r CXXFLAGS="-ma -O2 -qstrict -qoptimize=2 -qmaxmem=8192"
  5908.      ./configure --prefix=/usr/local/mysql
  5909.      --localstatedir=/usr/local/mysql/data
  5910.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5911.      --enable-thread-safe-client --enable-local-infile
  5912.      --with-named-z-libs=no --disable-shared --with-embedded-server
  5913.      --with-innodb'
  5914.  
  5915. HP-UX 10.20 pa-risc1.1 with `gcc' 3.1:
  5916.      `CFLAGS="-DHPUX -I/opt/dce/include -O3 -fPIC" CXX=gcc
  5917.      CXXFLAGS="-DHPUX -I/opt/dce /include -felide-constructors
  5918.      -fno-exceptions -fno-rtti -O3 -fPIC" ./configure
  5919.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5920.      --enable-thread-safe-client --enable-local-infile  --with-pthread
  5921.      --with-named-thread-libs=-ldce --with-lib-ccflags=-fPIC
  5922.      --disable-shared'
  5923.  
  5924. HP-UX 11.00 pa-risc with `aCC' (HP ANSI C++ B3910B A.03.50):
  5925.      `CC=cc CXX=aCC CFLAGS=+DAportable CXXFLAGS=+DAportable ./configure
  5926.      --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data
  5927.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5928.      --enable-thread-safe-client --enable-local-infile --disable-shared
  5929.      --with-embedded-server --with-innodb'
  5930.  
  5931. HP-UX 11.11 pa-risc2.0 64bit with `aCC' (HP ANSI C++ B3910B A.03.33):
  5932.      `CC=cc CXX=aCC CFLAGS=+DD64 CXXFLAGS=+DD64 ./configure
  5933.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5934.      --enable-thread-safe-client --enable-local-infile --disable-shared'
  5935.  
  5936. HP-UX 11.11 pa-risc2.0 32bit with `aCC' (HP ANSI C++ B3910B A.03.33):
  5937.      `CC=cc CXX=aCC CFLAGS="+DAportable" CXXFLAGS="+DAportable"
  5938.      ./configure --prefix=/usr/local/mysql
  5939.      --localstatedir=/usr/local/mysql/data
  5940.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5941.      --enable-thread-safe-client --enable-local-infile
  5942.      --disable-shared --with-innodb'
  5943.  
  5944. HP-UX 11.22 ia64 64bit with `aCC' (HP aC++/ANSI C B3910B A.05.50):
  5945.      `CC=cc CXX=aCC CFLAGS="+DD64 +DSitanium2" CXXFLAGS="+DD64
  5946.      +DSitanium2" ./configure --prefix=/usr/local/mysql
  5947.      --localstatedir=/usr/local/mysql/data
  5948.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5949.      --enable-thread-safe-client --enable-local-infile
  5950.      --disable-shared --with-embedded-server --with-innodb'
  5951.  
  5952. Apple Mac OS X 10.2 powerpc with `gcc' 3.1:
  5953.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5954.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5955.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5956.      --with-extra-charsets=complex --enable-thread-safe-client
  5957.      --enable-local-infile  --disable-shared'
  5958.  
  5959. FreeBSD 4.7 i386 with `gcc' 2.95.4:
  5960.      `CFLAGS=-DHAVE_BROKEN_REALPATH ./configure
  5961.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5962.      --enable-thread-safe-client --enable-local-infile
  5963.      --enable-assembler --with-named-z-libs=not-used --disable-shared'
  5964.  
  5965. FreeBSD 4.7 i386 using LinuxThreads with `gcc' 2.95.4:
  5966.      `CFLAGS="-DHAVE_BROKEN_REALPATH -D__USE_UNIX98 -D_REENTRANT
  5967.      -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads"
  5968.      CXXFLAGS="-DHAVE_BROKEN_REALPATH -D__USE_UNIX98 -D_REENTRANT
  5969.      -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads"
  5970.      ./configure --prefix=/usr/local/mysql
  5971.      --localstatedir=/usr/local/mysql/data
  5972.      --libexecdir=/usr/local/mysql/bin --enable-thread-safe-client
  5973.      --enable-local-infile --enable-assembler
  5974.      --with-named-thread-libs="-DHAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
  5975.      -D_THREAD_SAFE -I /usr/local/include/pthread/linuxthreads
  5976.      -L/usr/local/lib -llthread -llgcc_r" --disable-shared
  5977.      --with-embedded-server --with-innodb'
  5978.  
  5979. QNX Neutrino 6.2.1 i386 with `gcc' 2.95.3qnx-nto 20010315:
  5980.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5981.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5982.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5983.      --with-extra-charsets=complex --enable-thread-safe-client
  5984.      --enable-local-infile  --disable-shared'
  5985.  
  5986. The following binaries are built on third-party systems kindly provided
  5987. to MySQL AB by other users. These are provided only as a courtesy;
  5988. MySQL AB does not have full control over these systems, so we can
  5989. provide only limited support for the binaries built on them.
  5990.  
  5991. SCO Unix 3.2v5.0.6 i386 with `gcc' 2.95.3:
  5992.      `CFLAGS="-O3 -mpentium" LDFLAGS=-static CXX=gcc CXXFLAGS="-O3
  5993.      -mpentium -felide-constructors" ./configure
  5994.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5995.      --enable-thread-safe-client --enable-local-infile
  5996.      --with-named-z-libs=no --enable-thread-safe-client
  5997.      --disable-shared'
  5998.  
  5999. SCO OpenUnix 8.0.0 i386 with `CC' 3.2:
  6000.      `CC=cc CFLAGS="-O" CXX=CC ./configure --prefix=/usr/local/mysql
  6001.      --with-extra-charsets=complex --enable-thread-safe-client
  6002.      --enable-local-infile --with-named-z-libs=no
  6003.      --enable-thread-safe-client --disable-shared'
  6004.  
  6005. Compaq Tru64 OSF/1 V5.1 732 alpha with `cc/cxx' (Compaq C V6.3-029i / DIGITAL C++ V6.1-027):
  6006.      `CC="cc -pthread" CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline
  6007.      speed -speculate all" CXX="cxx -pthread" CXXFLAGS="-O4 -ansi_alias
  6008.      -fast -inline speed -speculate all -noexceptions -nortti"
  6009.      ./configure --prefix=/usr/local/mysql
  6010.      --with-extra-charsets=complex --enable-thread-safe-client
  6011.      --enable-local-infile --with-prefix=/usr/local/mysql
  6012.      --with-named-thread-libs="-lpthread -lmach -lexc -lc"
  6013.      --disable-shared --with-mysqld-ldflags=-all-static'
  6014.  
  6015. SGI Irix 6.5 IP32 with `gcc' 3.0.1:
  6016.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXXFLAGS="-O3
  6017.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  6018.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  6019.      --with-extra-charsets=complex --enable-thread-safe-client
  6020.      --enable-local-infile  --disable-shared'
  6021.  
  6022. FreeBSD/sparc64 5.0 with `gcc' 3.2.1:
  6023.      `CFLAGS=-DHAVE_BROKEN_REALPATH ./configure
  6024.      --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data
  6025.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  6026.      --enable-thread-safe-client --enable-local-infile --disable-shared
  6027.      --with-innodb'
  6028.  
  6029. The following compile options have been used for binary packages that
  6030. MySQL AB provided in the past. These binaries no longer are being
  6031. updated, but the compile options are listed here for reference purposes.
  6032.  
  6033. Linux 2.2.xx SPARC with `egcs' 1.1.2:
  6034.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  6035.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  6036.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  6037.      --with-extra-charsets=complex --enable-thread-safe-client
  6038.      --enable-local-infile --enable-assembler --disable-shared'
  6039.  
  6040. Linux 2.2.x with x686 with `gcc' 2.95.2:
  6041.      `CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro
  6042.      -felide-constructors -fno-exceptions -fno-rtti" ./configure
  6043.      --prefix=/usr/local/mysql --enable-assembler
  6044.      --with-mysqld-ldflags=-all-static --disable-shared
  6045.      --with-extra-charsets=complex'
  6046.  
  6047. SunOS 4.1.4 2 sun4c with `gcc' 2.7.2.1:
  6048.      `CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors" ./configure
  6049.      --prefix=/usr/local/mysql --disable-shared
  6050.      --with-extra-charsets=complex --enable-assembler'
  6051.  
  6052. SunOS 5.5.1 (and above) sun4u with `egcs' 1.0.3a or 2.90.27 or
  6053.      `gcc' 2.95.2 and newer: `CC=gcc CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3
  6054.      -felide-constructors -fno-exceptions -fno-rtti" ./configure
  6055.      --prefix=/usr/local/mysql --with-low-memory
  6056.      --with-extra-charsets=complex --enable-assembler'
  6057.  
  6058. SunOS 5.6 i86pc with `gcc' 2.8.1:
  6059.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  6060.      --with-low-memory --with-extra-charsets=complex'
  6061.  
  6062. BSDI BSD/OS 3.1 i386 with `gcc' 2.7.2.1:
  6063.      `CC=gcc CXX=gcc CXXFLAGS=-O ./configure --prefix=/usr/local/mysql
  6064.      --with-extra-charsets=complex'
  6065.  
  6066. BSDI BSD/OS 2.1 i386 with `gcc' 2.7.2:
  6067.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  6068.      --with-extra-charsets=complex'
  6069.  
  6070. AIX 4.2 with `gcc' 2.7.2.2:
  6071.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  6072.      --with-extra-charsets=complex'
  6073.  
  6074. Anyone who has more optimal options for any of the preceding
  6075. configurations listed can always mail them to the MySQL `internals'
  6076. mailing list.  *Note Mailing-list::.
  6077.  
  6078. RPM distributions prior to MySQL 3.22 are user-contributed.  Beginning
  6079. with MySQL 3.22, RPM distributions are generated by MySQL AB.
  6080.  
  6081. If you want to compile a debug version of MySQL, you should add
  6082. `--with-debug' or `--with-debug=full' to the preceding `configure'
  6083. commands and remove any `-fomit-frame-pointer' options.
  6084.  
  6085. How to Get MySQL
  6086. ----------------
  6087.  
  6088. Check the MySQL downloads page (`http://dev.mysql.com/downloads/') for
  6089. information about the current version and for downloading instructions.
  6090. For a complete up-to-date list of MySQL download mirror sites, see
  6091. `http://dev.mysql.com/downloads/mirrors.html'.  There you will also
  6092. find information about becoming a MySQL mirror site and how to report a
  6093. bad or out-of-date mirror.
  6094.  
  6095. Our main mirror is located at `http://mirrors.sunsite.dk/mysql/'.
  6096.  
  6097. Verifying Package Integrity Using MD5 Checksums or `GnuPG'
  6098. ----------------------------------------------------------
  6099.  
  6100. After you have downloaded the MySQL package that suits your needs and
  6101. before you attempt to install it, you should make sure that it is
  6102. intact and has not been tampered with. MySQL AB offers three means of
  6103. integrity checking:
  6104.  
  6105.    * MD5 checksums
  6106.  
  6107.    * Cryptographic signatures using `GnuPG', the GNU Privacy Guard
  6108.  
  6109.    * For RPM packages, the built-in RPM integrity verification mechanism
  6110.  
  6111.  
  6112. The following sections describe how to use these methods.
  6113.  
  6114. If you notice that the MD5 checksum or GPG signatures do not match,
  6115. first try to download the respective package one more time, perhaps
  6116. from another mirror site. If you repeatedly cannot successfully verify
  6117. the integrity of the package, please notify us about such incidents,
  6118. including the full package name and the download site you have been
  6119. using, at <webmaster@mysql.com> or <build@mysql.com>.  Do not report
  6120. downloading problems using the bug-reporting system.
  6121.  
  6122. Verifying the MD5 Checksum
  6123. ..........................
  6124.  
  6125. After you have downloaded a MySQL package, you should make sure that
  6126. its MD5 checksum matches the one provided on the MySQL download pages.
  6127. Each package has an individual checksum that you can verify with the
  6128. following command, where `package_name' is the name of the package you
  6129. downloaded:
  6130.  
  6131.      shell> md5sum package_name
  6132.  
  6133. Example:
  6134.      shell> md5sum mysql-standard-4.0.17-pc-linux-i686.tar.gz
  6135.      60f5fe969d61c8f82e4f7f62657e1f06  mysql-standard-4.0.17-pc-linux-i686.tar.gz
  6136.  
  6137. You should verify that the resulting checksum (the string of hexadecimal
  6138. digits) matches the one displayed on the download page immediately
  6139. below the respective package.
  6140.  
  6141. Note that not all operating systems support the `md5sum' command. On
  6142. some, it is simply called `md5' and others do not ship it at all. On
  6143. Linux, it is part of the `GNU Text Utilities' package, which is
  6144. available for a wide range of platforms. You can download the source
  6145. code from `http://www.gnu.org/software/textutils/' as well. If you have
  6146. `OpenSSL' installed, you can also use the command `openssl md5
  6147. package_name' instead. A DOS/Windows implementation of the `md5'
  6148. command is available from `http://www.fourmilab.ch/md5/'.
  6149.  
  6150. Signature Checking Using `GnuPG'
  6151. ................................
  6152.  
  6153. Another method of verifying the integrity and authenticity of a package
  6154. is to use cryptographic signatures. This is more reliable than using MD5
  6155. checksums, but requires more work.
  6156.  
  6157. Beginning with MySQL 4.0.10 (February 2003), MySQL AB started signing
  6158. downloadable packages with `GnuPG' (`GNU Privacy Guard').  `GnuPG' is
  6159. an Open Source alternative to the very well-known `Pretty Good Privacy'
  6160. (`PGP') by Phil Zimmermann.  See `http://www.gnupg.org/' for more
  6161. information about `GnuPG' and how to obtain and install it on your
  6162. system. Most Linux distributions already ship with `GnuPG' installed by
  6163. default.  For more information about `OpenPGP', see
  6164. `http://www.openpgp.org/'.
  6165.  
  6166. To verify the signature for a specific package, you first need to
  6167. obtain a copy of MySQL AB's public GPG build key. You can download the
  6168. key from `http://www.keyserver.net/'.  The key that you want to obtain
  6169. is named `build@mysql.com'.  Alternatively, you can cut and paste the
  6170. key directly from the following text:
  6171.  
  6172.      Key ID:
  6173.      pub  1024D/5072E1F5 2003-02-03
  6174.           MySQL Package signing key (www.mysql.com) <build@mysql.com>
  6175.      Fingerprint: A4A9 4068 76FC BD3C 4567  70C8 8C71 8D3B 5072 E1F5
  6176.      
  6177.      Public Key (ASCII-armored):
  6178.      
  6179.      -----BEGIN PGP PUBLIC KEY BLOCK-----
  6180.      Version: GnuPG v1.0.6 (GNU/Linux)
  6181.      Comment: For info see http://www.gnupg.org
  6182.      
  6183.      mQGiBD4+owwRBAC14GIfUfCyEDSIePvEW3SAFUdJBtoQHH/nJKZyQT7h9bPlUWC3
  6184.      RODjQReyCITRrdwyrKUGku2FmeVGwn2u2WmDMNABLnpprWPkBdCk96+OmSLN9brZ
  6185.      fw2vOUgCmYv2hW0hyDHuvYlQA/BThQoADgj8AW6/0Lo7V1W9/8VuHP0gQwCgvzV3
  6186.      BqOxRznNCRCRxAuAuVztHRcEAJooQK1+iSiunZMYD1WufeXfshc57S/+yeJkegNW
  6187.      hxwR9pRWVArNYJdDRT+rf2RUe3vpquKNQU/hnEIUHJRQqYHo8gTxvxXNQc7fJYLV
  6188.      K2HtkrPbP72vwsEKMYhhr0eKCbtLGfls9krjJ6sBgACyP/Vb7hiPwxh6rDZ7ITnE
  6189.      kYpXBACmWpP8NJTkamEnPCia2ZoOHODANwpUkP43I7jsDmgtobZX9qnrAXw+uNDI
  6190.      QJEXM6FSbi0LLtZciNlYsafwAPEOMDKpMqAK6IyisNtPvaLd8lH0bPAnWqcyefep
  6191.      rv0sxxqUEMcM3o7wwgfN83POkDasDbs3pjwPhxvhz6//62zQJ7Q7TXlTUUwgUGFj
  6192.      a2FnZSBzaWduaW5nIGtleSAod3d3Lm15c3FsLmNvbSkgPGJ1aWxkQG15c3FsLmNv
  6193.      bT6IXQQTEQIAHQUCPj6jDAUJCWYBgAULBwoDBAMVAwIDFgIBAheAAAoJEIxxjTtQ
  6194.      cuH1cY4AnilUwTXn8MatQOiG0a/bPxrvK/gCAJ4oinSNZRYTnblChwFaazt7PF3q
  6195.      zIhMBBMRAgAMBQI+PqPRBYMJZgC7AAoJEElQ4SqycpHyJOEAn1mxHijft00bKXvu
  6196.      cSo/pECUmppiAJ41M9MRVj5VcdH/KN/KjRtW6tHFPYhMBBMRAgAMBQI+QoIDBYMJ
  6197.      YiKJAAoJELb1zU3GuiQ/lpEAoIhpp6BozKI8p6eaabzF5MlJH58pAKCu/ROofK8J
  6198.      Eg2aLos+5zEYrB/LsrkCDQQ+PqMdEAgA7+GJfxbMdY4wslPnjH9rF4N2qfWsEN/l
  6199.      xaZoJYc3a6M02WCnHl6ahT2/tBK2w1QI4YFteR47gCvtgb6O1JHffOo2HfLmRDRi
  6200.      Rjd1DTCHqeyX7CHhcghj/dNRlW2Z0l5QFEcmV9U0Vhp3aFfWC4Ujfs3LU+hkAWzE
  6201.      7zaD5cH9J7yv/6xuZVw411x0h4UqsTcWMu0iM1BzELqX1DY7LwoPEb/O9Rkbf4fm
  6202.      Le11EzIaCa4PqARXQZc4dhSinMt6K3X4BrRsKTfozBu74F47D8Ilbf5vSYHbuE5p
  6203.      /1oIDznkg/p8kW+3FxuWrycciqFTcNz215yyX39LXFnlLzKUb/F5GwADBQf+Lwqq
  6204.      a8CGrRfsOAJxim63CHfty5mUc5rUSnTslGYEIOCR1BeQauyPZbPDsDD9MZ1ZaSaf
  6205.      anFvwFG6Llx9xkU7tzq+vKLoWkm4u5xf3vn55VjnSd1aQ9eQnUcXiL4cnBGoTbOW
  6206.      I39EcyzgslzBdC++MPjcQTcA7p6JUVsP6oAB3FQWg54tuUo0Ec8bsM8b3Ev42Lmu
  6207.      QT5NdKHGwHsXTPtl0klk4bQk4OajHsiy1BMahpT27jWjJlMiJc+IWJ0mghkKHt92
  6208.      6s/ymfdf5HkdQ1cyvsz5tryVI3Fx78XeSYfQvuuwqp2H139pXGEkg0n6KdUOetdZ
  6209.      Whe70YGNPw1yjWJT1IhMBBgRAgAMBQI+PqMdBQkJZgGAAAoJEIxxjTtQcuH17p4A
  6210.      n3r1QpVC9yhnW2cSAjq+kr72GX0eAJ4295kl6NxYEuFApmr1+0uUq/SlsQ==
  6211.      =YJkx
  6212.      -----END PGP PUBLIC KEY BLOCK-----
  6213.  
  6214. You can import the build key into your personal public GPG keyring by
  6215. using `gpg --import'. For example, if you save the key in a file named
  6216. `mysql_pubkey.asc', the import command looks like this:
  6217.  
  6218.      shell> gpg --import mysql_pubkey.asc
  6219.  
  6220. See the GPG documentation for more information on how to work with
  6221. public keys.
  6222.  
  6223. After you have downloaded and imported the public build key, download
  6224. your desired MySQL package and the corresponding signature, which also
  6225. is available from the download page.  The signature file has the same
  6226. name as the distribution file with an `.asc' extension. For example:
  6227.  
  6228. Distribution file      `mysql-standard-4.0.17-pc-linux-i686.tar.gz'
  6229. Signature file         `mysql-standard-4.0.17-pc-linux-i686.tar.gz.asc'
  6230.  
  6231. Make sure that both files are stored in the same directory and then run
  6232. the following command to verify the signature for the distribution file:
  6233.  
  6234.      shell> gpg --verify package_name.asc
  6235.  
  6236. Example:
  6237.  
  6238.      shell> gpg --verify mysql-standard-4.0.17-pc-linux-i686.tar.gz.asc
  6239.      gpg: Warning: using insecure memory!
  6240.      gpg: Signature made Mon 03 Feb 2003 08:50:39 PM MET
  6241.      using DSA key ID 5072E1F5
  6242.      gpg: Good signature from
  6243.           "MySQL Package signing key (www.mysql.com) <build@mysql.com>"
  6244.  
  6245. The `Good signature' message indicates that everything is all right.
  6246. You can ignore the `insecure memory' warning.
  6247.  
  6248. Signature Checking Using `RPM'
  6249. ..............................
  6250.  
  6251. For RPM packages, there is no separate signature. RPM packages have a
  6252. built-in GPG signature and MD5 checksum. You can verify a package by
  6253. running the following command:
  6254.  
  6255.      shell> rpm --checksig package_name.rpm
  6256.  
  6257. Example:
  6258.  
  6259.      shell> rpm --checksig MySQL-server-4.0.10-0.i386.rpm
  6260.      MySQL-server-4.0.10-0.i386.rpm: md5 gpg OK
  6261.  
  6262. *Note*: If you are using RPM 4.1 and it complains about `(GPG) NOT OK
  6263. (MISSING KEYS: GPG#5072e1f5)', even though you have imported the MySQL
  6264. public build key into your own GPG keyring, you need to import the key
  6265. into the RPM keyring first. RPM 4.1 no longer uses your personal GPG
  6266. keyring (or GPG itself). Rather, it maintains its own keyring because
  6267. it is a system-wide application and a user's GPG public keyring is a
  6268. user-specific file. To import the MySQL public key into the RPM
  6269. keyring, first obtain the key as described in the previous section.
  6270. Then use `rpm --import' to import the key.  For example, if you have
  6271. the public key stored in a file named `mysql_pubkey.asc', import it
  6272. using this command:
  6273.  
  6274.      shell> rpm --import mysql_pubkey.asc
  6275.  
  6276. Installation Layouts
  6277. --------------------
  6278.  
  6279. This section describes the default layout of the directories created by
  6280. installing binary or source distributions provided by MySQL AB. If you
  6281. install a distribution provided by another vendor, some other layout
  6282. might be used.
  6283.  
  6284. On Windows, the default installation directory is `C:\mysql', which has
  6285. the following subdirectories:
  6286.  
  6287. *Directory*               *Contents of Directory*
  6288. `bin'                     Client programs and the
  6289.                           `mysqld' server
  6290. `data'                    Log files, databases
  6291. `Docs'                    Documentation
  6292. `examples'                Example programs and scripts
  6293. `include'                 Include (header) files
  6294. `lib'                     Libraries
  6295. `scripts'                 Utility scripts
  6296. `share'                   Error message files
  6297.  
  6298. Installations created from Linux RPM distributions result in files under
  6299. the following system directories:
  6300.  
  6301. *Directory*               *Contents of Directory*
  6302. `/usr/bin'                Client programs and scripts
  6303. `/usr/sbin'               The `mysqld' server
  6304. `/var/lib/mysql'          Log files, databases
  6305. `/usr/share/doc/packages' Documentation
  6306. `/usr/include/mysql'      Include (header) files
  6307. `/usr/lib/mysql'          Libraries
  6308. `/usr/share/mysql'        Error message and character set
  6309.                           files
  6310. `/usr/share/sql-bench'    Benchmarks
  6311.  
  6312. On Unix, a `tar' file binary distribution is installed by unpacking it
  6313. at the installation location you choose (typically `/usr/local/mysql')
  6314. and creates the following directories in that location:
  6315.  
  6316. *Directory*               *Contents of Directory*
  6317. `bin'                     Client programs and the
  6318.                           `mysqld' server
  6319. `data'                    Log files, databases
  6320. `docs'                    Documentation, ChangeLog
  6321. `include'                 Include (header) files
  6322. `lib'                     Libraries
  6323. `scripts'                 `mysql_install_db'
  6324. `share/mysql'             Error message files
  6325. `sql-bench'               Benchmarks
  6326.  
  6327. A source distribution is installed after you configure and compile it.
  6328. By default, the installation step installs files under `/usr/local', in
  6329. the following subdirectories:
  6330.  
  6331. *Directory*               *Contents of Directory*
  6332. `bin'                     Client programs and scripts
  6333. `include/mysql'           Include (header) files
  6334. `info'                    Documentation in Info format
  6335. `lib/mysql'               Libraries
  6336. `libexec'                 The `mysqld' server
  6337. `share/mysql'             Error message files
  6338. `sql-bench'               Benchmarks and `crash-me' test
  6339. `var'                     Databases and log files
  6340.  
  6341. Within an installation directory, the layout of a source installation
  6342. differs from that of a binary installation in the following ways:
  6343.  
  6344.    * The `mysqld' server is installed in the `libexec' directory rather
  6345.      than in the `bin' directory.
  6346.  
  6347.    * The data directory is `var' rather than `data'.
  6348.  
  6349.    * `mysql_install_db' is installed in the `bin' directory rather than
  6350.      in the `scripts' directory.
  6351.  
  6352.    * The header file and library directories are `include/mysql' and
  6353.      `lib/mysql' rather than `include' and `lib'.
  6354.  
  6355. You can create your own binary installation from a compiled source
  6356. distribution by executing the `scripts/make_binary_distribution' script
  6357. from the top directory of the source distribution.
  6358.  
  6359. Standard MySQL Installation Using a Binary Distribution
  6360. =======================================================
  6361.  
  6362. This section covers the installation of MySQL on platforms where we
  6363. offer packages using the native packaging format of the respective
  6364. platform. (This is also known as performing a "binary install.")
  6365. However, binary distributions of MySQL are available for many other
  6366. platforms as well. See *Note Installing binary:: for generic
  6367. installation instructions for these packages that apply to all
  6368. platforms.
  6369.  
  6370. See *Note General Installation Issues:: for more information on what
  6371. other binary distributions are available and how to obtain them.
  6372.  
  6373. Installing MySQL on Windows
  6374. ---------------------------
  6375.  
  6376. The installation process for MySQL on Windows has the following steps:
  6377.  
  6378.   1. Obtain and install the distribution.
  6379.  
  6380.   2. Set up an option file if necessary.
  6381.  
  6382.   3. Select the server you want to use.
  6383.  
  6384.   4. Start the server.
  6385.  
  6386.   5. Assign passwords to the initial MySQL accounts.
  6387.  
  6388.  
  6389. MySQL for Windows is available in two distribution formats:
  6390.  
  6391.    * The binary distribution contains a setup program that installs
  6392.      everything you need so that you can start the server immediately.
  6393.  
  6394.    * The source distribution contains all the code and support files
  6395.      for building the executables using the VC++ 6.0 compiler.
  6396.  
  6397.  
  6398. Generally speaking, you should use the binary distribution. It's
  6399. simpler, and you need no additional tools to get MySQL up and running.
  6400.  
  6401. This section describes how to install MySQL on Windows using a binary
  6402. distribution.  To install using a source distribution, see *Note
  6403. Windows source build::.
  6404.  
  6405. Windows System Requirements
  6406. ...........................
  6407.  
  6408. To run MySQL on Windows, you need the following:
  6409.  
  6410.    * A 32-bit Windows operating system such as 9x, Me, NT, 2000, or XP.
  6411.      The NT family (Windows NT, 2000, and XP) permits you to run the
  6412.      MySQL server as a service. *Note NT start::.
  6413.  
  6414.    * TCP/IP protocol support.
  6415.  
  6416.    * A copy of the MySQL binary distribution for Windows, which can be
  6417.      downloaded from `http://dev.mysql.com/downloads/'.  *Note Getting
  6418.      MySQL::.
  6419.  
  6420.      Note: If you download the distribution via FTP, we recommend the
  6421.      use of an adequate FTP client with a resume feature to avoid
  6422.      corruption of files during the download process.
  6423.  
  6424.    * `WinZip' or other Windows tool that can read `.zip' files, to
  6425.      unpack the distribution file.
  6426.  
  6427.    * Enough space on the hard drive to unpack, install, and create the
  6428.      databases in accordance with your requirements.
  6429.  
  6430.    * If you plan to connect to the MySQL server via ODBC, you also need
  6431.      a Connector/ODBC driver. *Note ODBC Connector::.
  6432.  
  6433.    * If you need tables with a size larger than 4GB, install MySQL on
  6434.      an NTFS or newer filesystem. Don't forget to use `MAX_ROWS' and
  6435.      `AVG_ROW_LENGTH' when you create tables.  *Note `CREATE TABLE':
  6436.      CREATE TABLE.
  6437.  
  6438.  
  6439. Installing a Windows Binary Distribution
  6440. ........................................
  6441.  
  6442. To install MySQL on Windows using a binary distribution, follow this
  6443. procedure:
  6444.  
  6445.   1. If you are working on a Windows NT, 2000, or XP machine, make sure
  6446.      that you have logged in as a user with administrator privileges.
  6447.  
  6448.   2. If you are doing an upgrade of an earlier MySQL installation, it
  6449.      is necessary to stop the current server.  On Windows NT, 2000, or
  6450.      XP machines, if you are running the server as a Windows service,
  6451.      stop it as follows from the command prompt:
  6452.  
  6453.           C:\> NET STOP MySQL
  6454.  
  6455.      If you plan to use a different server after the upgrade (for
  6456.      example, if you want to run `mysqld-max' rather than `mysqld'),
  6457.      remove the existing service:
  6458.  
  6459.           C:\> C:\mysql\bin\mysqld --remove
  6460.  
  6461.      You can reinstall the service to use the proper server after
  6462.      upgrading.
  6463.  
  6464.      If you are not running the MySQL server as a service, stop it like
  6465.      this:
  6466.  
  6467.           C:\> C:\mysql\bin\mysqladmin -u root shutdown
  6468.  
  6469.   3. Exit the `WinMySQLAdmin' program if it is running.
  6470.  
  6471.   4. Unzip the distribution file to a temporary directory.
  6472.  
  6473.   5. Run the `setup.exe' program to begin the installation process.  If
  6474.      you want to install MySQL into a location other than the default
  6475.      directory (`C:\mysql'), use the `Browse' button to specify your
  6476.      preferred directory. If you do not install MySQL into the default
  6477.      location, you will need to specify the location whenever you start
  6478.      the server. The easiest way to do this is to use an option file,
  6479.      as described in *Note Windows prepare environment::.
  6480.  
  6481.   6. Finish the install process.
  6482.  
  6483.  
  6484. *Important note:* Early alpha Windows distributions for MySQL 4.1 do
  6485. not contain an installer program.  A 4.1 distribution is a Zip file
  6486. that you just unzip in the location where you want to install MySQL.
  6487. For example, to install `mysql-4.1.1-alpha-win.zip' as `C:\mysql', unzip
  6488. the distribution file on the `C:' drive, then rename the resulting
  6489. `mysql-4.1.1-alpha' directory to `mysql'.
  6490.  
  6491. If you are upgrading to MySQL 4.1 from an earlier version, you will
  6492. want to preserve your existing `data' directory that contains the grant
  6493. tables in the `mysql' database and your own databases.  Before
  6494. installing 4.1, stop the server if it is running, and save your `data'
  6495. directory to another location. Then either rename the existing
  6496. `C:\mysql' directory or remove it.  Install 4.1 as described in the
  6497. preceding paragraph, and then replace its `data' directory with your
  6498. old `data' directory.  This will avoid the loss of your current
  6499. databases.  Start the new server and update the grant tables.  *Note
  6500. Upgrading-grant-tables::.
  6501.  
  6502. Please see *Note Windows troubleshooting:: if you encounter
  6503. difficulties during installation.
  6504.  
  6505. Preparing the Windows MySQL Environment
  6506. .......................................
  6507.  
  6508. If you need to specify startup options when you run the server, you can
  6509. indicate them on the command line or place them in an option file. For
  6510. options that will be used every time the server starts, you will find
  6511. it most convenient to use an option file to specify your MySQL
  6512. configuration. This is true particularly under the following
  6513. circumstances:
  6514.  
  6515.    * The installation or data directory locations are different from
  6516.      the default locations (`C:\mysql' and `C:\mysql\data').
  6517.  
  6518.    * You need to tune the server settings.  For example, to use the
  6519.      `InnoDB' transactional tables in MySQL 3.23, you must manually add
  6520.      some extra lines to the option file, as described in *Note
  6521.      `InnoDB' configuration: InnoDB configuration.  (As of MySQL 4.0,
  6522.      `InnoDB' creates its data files and log files in the data
  6523.      directory by default. This means you need not configure `InnoDB'
  6524.      explicitly.  You may still do so if you wish, and an option file
  6525.      will be useful in this case, too.)
  6526.  
  6527.  
  6528. On Windows, the MySQL installer places the data directory directly under
  6529. the directory where you install MySQL.  If you would like to use a data
  6530. directory in a different location, you should copy the entire contents
  6531. of the `data' directory to the new location. For example, by default,
  6532. the installer places MySQL in `C:\mysql' and the data directory in
  6533. `C:\mysql\data'. If you want to use a data directory of `E:\mydata',
  6534. you must do two things:
  6535.  
  6536.    * Move the data directory from `C:\mysql\data' to `E:\mydata'.
  6537.  
  6538.    * Use a `--datadir' option to specify the new data directory location
  6539.      each time you start the server.
  6540.  
  6541.  
  6542. When the MySQL server starts on Windows, it looks for options in two
  6543. files:  the `my.ini' file in the Windows directory, and the `C:\my.cnf'
  6544. file.  The Windows directory typically is named something like
  6545. `C:\WINDOWS' or `C:\WinNT'.  You can determine its exact location from
  6546. the value of the `WINDIR' environment variable using the following
  6547. command:
  6548.  
  6549.      C:\> echo %WINDIR%
  6550.  
  6551. MySQL looks for options first in the `my.ini' file, then in the
  6552. `my.cnf' file.  However, to avoid confusion, it's best if you use only
  6553. one file.  If your PC uses a boot loader where the `C:' drive isn't the
  6554. boot drive, your only option is to use the `my.ini' file.  Whichever
  6555. option file you use, it must be a plain text file.
  6556.  
  6557. An option file can be created and modified with any text editor, such
  6558. as the `Notepad' program.  For example, if MySQL is installed at
  6559. `E:\mysql' and the data directory is located at `E:\mydata\data', you
  6560. can create the option file and set up a `[mysqld]' section to specify
  6561. values for the `basedir' and `datadir' parameters:
  6562.  
  6563.      [mysqld]
  6564.      # set basedir to your installation path
  6565.      basedir=E:/mysql
  6566.      # set datadir to the location of your data directory
  6567.      datadir=E:/mydata/data
  6568.  
  6569. Note that Windows pathnames are specified in option files using forward
  6570. slashes rather than backslashes.  If you do use backslashes, you must
  6571. double them.
  6572.  
  6573. Another way to manage an option file is to use the `WinMySQLAdmin'
  6574. tool. You can find `WinMySQLAdmin' in the `bin' directory of your MySQL
  6575. installation, as well as a help file containing instructions for using
  6576. it. `WinMySQLAdmin' has the capability of editing your option file, but
  6577. note these points:
  6578.  
  6579.    * `WinMySQLAdmin' uses only the `my.ini' file.
  6580.  
  6581.    * If `WinMySQLAdmin' finds a `C:\my.cnf' file, it will in fact rename
  6582.      it to `C:\my_cnf.bak' to disable it.
  6583.  
  6584.  
  6585. Now you are ready to start the server.
  6586.  
  6587. Selecting a Windows Server
  6588. ..........................
  6589.  
  6590. Starting with MySQL 3.23.38, the Windows distribution includes both the
  6591. normal and the MySQL-Max server binaries.
  6592.  
  6593. Up through the early releases of MySQL 4.1, the servers included in
  6594. Windows distributions are named like this:
  6595.  
  6596. *Binary*       *Description*
  6597. `mysqld'       Compiled with full debugging and automatic memory
  6598.                allocation checking, symbolic links, and `InnoDB' and
  6599.                `BDB' tables.
  6600. `mysqld-opt'   Optimized binary.  From version 4.0 on, `InnoDB' is
  6601.                enabled.  Before 4.0, this server includes no
  6602.                transactional table support.
  6603. `mysqld-nt'    Optimized binary for Windows NT, 2000, and XP with
  6604.                support for named pipes.
  6605. `mysqld-max'   Optimized binary with support for symbolic links, and
  6606.                `InnoDB' and `BDB' tables.
  6607. `mysqld-max-nt'Like `mysqld-max', but compiled with support for named
  6608.                pipes.
  6609.  
  6610. We have found that the server with the most generic name (`mysqld') is
  6611. the one that many users are likely to choose by default. However, that
  6612. is also the server that results in the highest memory and CPU use due
  6613. to the inclusion of full debugging support.  The server named
  6614. `mysqld-opt' is a better general-use server choice to make instead if
  6615. you don't need debugging suport and don't want the maximal feature set
  6616. offered by the `-max' servers or named pipe support offered by the
  6617. `-nt' servers.
  6618.  
  6619. To make it less likely that the debugging server would be chosen
  6620. inadvertantly, some name changes were made from MySQL 4.1.2 to 4.1.4:
  6621. `mysqld' has been renamed to `mysqld-debug' and `mysqld-opt' has been
  6622. renamed to `mysqld'.  Thus, the server that includes debugging support
  6623. indicates that in its name, and the server named `mysqld' is an
  6624. efficient default choice. The other servers still have their same
  6625. names. The resulting servers are named like this:
  6626.  
  6627. *Binary*       *Description*
  6628. `mysqld-debug' Compiled with full debugging and automatic memory
  6629.                allocation checking, symbolic links, and `InnoDB' and
  6630.                `BDB' tables.
  6631. `mysqld'       Optimized binary with `InnoDB' support.
  6632. `mysqld-nt'    Optimized binary for Windows NT, 2000, and XP with
  6633.                support for named pipes.
  6634. `mysqld-max'   Optimized binary with support for symbolic links, and
  6635.                `InnoDB' and `BDB' tables.
  6636. `mysqld-max-nt'Like `mysqld-max', but compiled with support for named
  6637.                pipes.
  6638.  
  6639. The name changes were not both instituted at the same time. If you have
  6640. MySQL 4.1.2 or 4.1.3, it might be that you have a server named
  6641. `mysqld-debug' but not one named `mysqld'. In this case, you should
  6642. have have a server `mysqld-opt', which you should choose as your
  6643. default server unless you need maximal features, named pipes, or
  6644. debugging support.
  6645.  
  6646. All of the preceding binaries are optimized for modern Intel processors,
  6647. but should work on any Intel i386-class or higher processor.
  6648.  
  6649. MySQL supports TCP/IP on all Windows platforms. The `mysqld-nt' and
  6650. `mysql-max-nt' servers support named pipes on NT, 2000, and XP.
  6651. However, the default is to use TCP/IP regardless of the platform.
  6652. (Named pipes are slower than TCP/IP in many Windows configurations.)
  6653. Named pipe use is subject to these conditions:
  6654.  
  6655.    * Starting from MySQL 3.23.50, named pipes are enabled only if you
  6656.      start the server with the `--enable-named-pipe' option.  It is now
  6657.      necessary to use this option explicitly because some users have
  6658.      experienced problems shutting down the MySQL server when named
  6659.      pipes were used.
  6660.  
  6661.    * Named pipe connections are allowed only by the `mysqld-nt' or
  6662.      `mysqld-max-nt' servers, and only if the server is run on a
  6663.      version of Windows that supports named pipes (NT, 2000, XP).
  6664.  
  6665.    * These servers can be run on Windows 98 or Me, but only if TCP/IP
  6666.      is installed; named pipe connections cannot be used.
  6667.  
  6668.    * On Windows 95, these servers cannot be used.
  6669.  
  6670.  
  6671. *Note*: Most of the examples in the following sections use `mysqld' as
  6672. the server name. If you choose to use a different server, such as
  6673. `mysqld-opt', make the appropriate substitutions in the commands that
  6674. are shown in the examples. One good reason to choose a different server
  6675. is that because `mysqld' contains full debugging support, it uses more
  6676. memory and runs slower than the other Windows servers.
  6677.  
  6678. Starting the Server for the First Time
  6679. ......................................
  6680.  
  6681. On Windows 95, 98, or Me, MySQL clients always connect to the server
  6682. using TCP/IP.  (This will allow any machine on your network to connect
  6683. to your MySQL server.)  Because of this, you must make sure that TCP/IP
  6684. support is installed on your machine before starting MySQL.  You can
  6685. find TCP/IP on your Windows CD-ROM.
  6686.  
  6687. Note that if you are using an old Windows 95 release (for example,
  6688. OSR2), it's likely that you have an old Winsock package; MySQL requires
  6689. Winsock 2! You can get the newest Winsock from
  6690. `http://www.microsoft.com/'.  Windows 98 has the new Winsock 2 library,
  6691. so it is unnecessary to update the library.
  6692.  
  6693. On NT-based systems such as Windows NT, 2000, or XP, clients have two
  6694. options. They can use TCP/IP, or they can use a named pipe if the server
  6695. supports named pipe connections.
  6696.  
  6697. In MySQL 4.1 and up, Windows servers also support shared-memory
  6698. connections if started with the `--shared-memory' option.  Clients can
  6699. connect this way by using the `--protocol=memory' option.
  6700.  
  6701. For information about which server binary to run, see *Note Windows
  6702. select server::.
  6703.  
  6704. This section gives a general overview of starting the MySQL server.
  6705. The following sections provide more specific information for particular
  6706. versions of Windows.
  6707.  
  6708. The examples in these sections assume that MySQL is installed under the
  6709. default location of `C:\mysql'. Adjust the pathnames shown in the
  6710. examples if you have MySQL installed in a different location.
  6711.  
  6712. Testing is best done from a command prompt in a console window (a "DOS
  6713. window"). This way you can have the server display status messages in
  6714. the window where they are easy to see.  If something is wrong with your
  6715. configuration, these messages will make it easier for you to identify
  6716. and fix any problems.
  6717.  
  6718. To start the server, enter this command:
  6719.  
  6720.      C:\> C:\mysql\bin\mysqld --console
  6721.  
  6722. For servers that include `InnoDB' support, you should see the following
  6723. messages as the server starts:
  6724.  
  6725.      InnoDB: The first specified datafile c:\ibdata\ibdata1 did not exist:
  6726.      InnoDB: a new database to be created!
  6727.      InnoDB: Setting file c:\ibdata\ibdata1 size to 209715200
  6728.      InnoDB: Database physically writes the file full: wait...
  6729.      InnoDB: Log file c:\iblogs\ib_logfile0 did not exist: new to be created
  6730.      InnoDB: Setting log file c:\iblogs\ib_logfile0 size to 31457280
  6731.      InnoDB: Log file c:\iblogs\ib_logfile1 did not exist: new to be created
  6732.      InnoDB: Setting log file c:\iblogs\ib_logfile1 size to 31457280
  6733.      InnoDB: Log file c:\iblogs\ib_logfile2 did not exist: new to be created
  6734.      InnoDB: Setting log file c:\iblogs\ib_logfile2 size to 31457280
  6735.      InnoDB: Doublewrite buffer not found: creating new
  6736.      InnoDB: Doublewrite buffer created
  6737.      InnoDB: creating foreign key constraint system tables
  6738.      InnoDB: foreign key constraint system tables created
  6739.      011024 10:58:25  InnoDB: Started
  6740.  
  6741. When the server finishes its startup sequence, you should see something
  6742. like this, which indicates that the server is ready to service client
  6743. connections:
  6744.  
  6745.      mysqld: ready for connections
  6746.      Version: '4.0.14-log'  socket: ''  port: 3306
  6747.  
  6748. The server will continue to write to the console any further diagnostic
  6749. output it produces.  You can open a new console window in which to run
  6750. client programs.
  6751.  
  6752. If you omit the `--console' option, the server writes diagnostic output
  6753. to the error log in the data directory (`C:\mysql\data' by default).
  6754. The error log is the file with the `.err' extension.
  6755.  
  6756. *Note*: The accounts that are listed in the MySQL grant tables
  6757. initially have no passwords.  After starting the server, you should set
  6758. up passwords for them using the instructions in *Note
  6759. Post-installation::.
  6760.  
  6761. Starting MySQL from the Windows Command Line
  6762. ............................................
  6763.  
  6764. The MySQL server can be started manually from the command line.  This
  6765. can be done on any version of Windows.
  6766.  
  6767. To start the `mysqld' server from the command line, you should start a
  6768. console window (a "DOS window") and enter this command:
  6769.  
  6770.      C:\> C:\mysql\bin\mysqld
  6771.  
  6772. On non-NT versions of Windows, this will start `mysqld' in the
  6773. background. That is, after the server starts, you should see another
  6774. command prompt. If you start the server this way on Windows NT, 2000,
  6775. or XP, the server will run in the foreground and no command prompt will
  6776. appear until the server exits.  Because of this, you should open
  6777. another console window to run client programs while the server is
  6778. running.
  6779.  
  6780. You can stop the MySQL server by executing this command:
  6781.  
  6782.      C:\> C:\mysql\bin\mysqladmin -u root shutdown
  6783.  
  6784. This invokes the MySQL administrative utility `mysqladmin' to connect
  6785. to the server and tell it to shut down. The command connects as `root',
  6786. which is the default administrative account in the MySQL grant system.
  6787. Note that users in the MySQL grant system are wholly independent from
  6788. any login users under Windows.
  6789.  
  6790. If `mysqld' doesn't start, check the error log to see whether the
  6791. server wrote any messages there to indicate the cause of the problem.
  6792. The error log is located in the `C:\mysql\data' directory. It is the
  6793. file with a suffix of `.err'. You can also try to start the server as
  6794. `mysqld --console'; in this case, you may get some useful information
  6795. on the screen that may help solve the problem.
  6796.  
  6797. The last option is to start `mysqld' with `--standalone --debug'.  In
  6798. this case, `mysqld' will write a log file `C:\mysqld.trace' that should
  6799. contain the reason why `mysqld' doesn't start. *Note Making trace
  6800. files::.
  6801.  
  6802. Use `mysqld --help' to display all the options that `mysqld'
  6803. understands!
  6804.  
  6805. Starting MySQL as a Windows Service
  6806. ...................................
  6807.  
  6808. On the NT family (Windows NT, 2000, or XP), the recommended way to run
  6809. MySQL is to install it as a Windows service. Then Windows starts and
  6810. stops the MySQL server automatically when Windows starts and stops. A
  6811. server installed as a service can also be controlled from the command
  6812. line using `NET' commands, or with the graphical `Services' utility.
  6813.  
  6814. The `Services' utility (the Windows `Service Control Manager') can be
  6815. found in the Windows `Control Panel' (under `Administrative Tools' on
  6816. Windows 2000 or XP). It is advisable to close the `Services' utility
  6817. while performing server installation or removal operations from this
  6818. command line.  This prevents some odd errors.
  6819.  
  6820. To get MySQL to work with TCP/IP on Windows NT 4, you must install
  6821. service pack 3 (or newer).
  6822.  
  6823. Before installing MySQL as a Windows service, you should first stop the
  6824. current server if it is running by using the following command:
  6825.  
  6826.      C:\> C:\mysql\bin\mysqladmin -u root shutdown
  6827.  
  6828. This invokes the MySQL administrative utility `mysqladmin' to connect
  6829. to the server and tell it to shut down. The command connects as `root',
  6830. which is the default administrative account in the MySQL grant system.
  6831. Note that users in the MySQL grant system are wholly independent from
  6832. any login users under Windows.
  6833.  
  6834. Now install the server as a service:
  6835.  
  6836.      C:\> mysqld --install
  6837.  
  6838. If you have problems installing `mysqld' as a service using just the
  6839. server name, try installing it using its full pathname:
  6840.  
  6841.      C:\> C:\mysql\bin\mysqld --install
  6842.  
  6843. As of MySQL 4.0.2, you can specify a specific service name after the
  6844. `--install' option.  As of MySQL 4.0.3, you can in addition specify a
  6845. `--defaults-file' option after the service name to indicate where the
  6846. server should obtain options when it starts. The rules that determine
  6847. the service name and option files the server uses are as follows:
  6848.  
  6849.    * If you specify no service name, the server uses the default
  6850.      service name of `MySQL' and the server reads options from the
  6851.      `[mysqld]' group in the standard option files.
  6852.  
  6853.    * If you specify a service name after the `--install' option, the
  6854.      server ignores the `[mysqld]' option group and instead reads
  6855.      options from the group that has the same name as the service. The
  6856.      server reads options from the standard option files.
  6857.  
  6858.    * If you specify a `--defaults-file' option after the service name,
  6859.      the server ignores the standard option files and reads options
  6860.      only from the `[mysqld]' group of the named file.
  6861.  
  6862.  
  6863. *Note*: Prior to MySQL 4.0.17, a server installed as a Windows service
  6864. has problems starting if its pathname or the service name contains
  6865. spaces. For this reason, avoid installing MySQL in a directory such as
  6866. `C:\Program Files' or using a service name containing spaces.
  6867.  
  6868. In the usual case that you install the server with `--install' but no
  6869. service name, the server is installed with a service name of `MySQL'.
  6870.  
  6871. As a more complex example, consider the following command:
  6872.  
  6873.      C:\> C:\mysql\bin\mysqld --install mysql --defaults-file=C:\my-opts.cnf
  6874.  
  6875. Here, a service name is given after the `--install' option. If no
  6876. `--defaults-file' option had been given, this command would have the
  6877. effect of causing the server to read the `[mysql]' group from the
  6878. standard option files. (This would be a bad idea, because that option
  6879. group is for use by the `mysql' client program.) However, because the
  6880. `--defaults-file' option is present, the server reads options only from
  6881. the named file, and only from the `[mysqld]' option group.
  6882.  
  6883. You can also specify options as "`Start parameters'" in the Windows
  6884. `Services' utility before you start the MySQL service.
  6885.  
  6886. Once a MySQL server is installed as a service, Windows will start the
  6887. service automatically whenever Windows starts.  The service also can be
  6888. started immediately from the `Services' utility, or by using the
  6889. command `NET START MySQL'.  The `NET' command is not case sensitive.
  6890.  
  6891. When run as a service, `mysqld' has no access to a console window, so
  6892. no messages can be seen there.  If `mysqld' doesn't start, check the
  6893. error log to see whether the server wrote any messages there to
  6894. indicate the cause of the problem.  The error log is located in the
  6895. `C:\mysql\data' directory. It is the file with a suffix of `.err'.
  6896.  
  6897. When `mysqld' is running as a service, it can be stopped by using the
  6898. `Services' utility, the command `NET STOP MySQL', or the command
  6899. `mysqladmin shutdown'. If the service is running when Windows shuts
  6900. down, Windows will stop the server automatically.
  6901.  
  6902. From MySQL 3.23.44 on, you have the choice of installing the server as
  6903. a `Manual' service if you don't wish the service to be started
  6904. automatically during the boot process. To do this, use the
  6905. `--install-manual' option rather than the `--install' option:
  6906.  
  6907.      C:\> C:\mysql\bin\mysqld --install-manual
  6908.  
  6909. To remove a server that is installed as a service, first stop it if it
  6910. is running. Then use the `--remove' option to remove it:
  6911.  
  6912.      C:\> C:\mysql\bin\mysqld --remove
  6913.  
  6914. For MySQL versions older than 3.23.49, one problem with automatic MySQL
  6915. service shutdown is that Windows waited only for a few seconds for the
  6916. shutdown to complete, then killed the database server process if the
  6917. time limit was exceeded. This had the potential to cause problems.
  6918. (For example, the `InnoDB' storage engine had to perform crash recovery
  6919. at the next startup.) Starting from MySQL 3.23.49, Windows waits longer
  6920. for the MySQL server shutdown to complete. If you notice this still is
  6921. not enough for your installation, it is safest not to run the MySQL
  6922. server as a service. Instead, start it from the command-line prompt,
  6923. and stop it with `mysqladmin shutdown'.
  6924.  
  6925. This change to tell Windows to wait longer when stopping the MySQL
  6926. server works for Windows 2000 and XP. It does not work for Windows NT,
  6927. where Windows waits only 20 seconds for a service to shut down, and
  6928. after that kills the service process. You can increase this default by
  6929. opening the Registry Editor `\winnt\system32\regedt32.exe' and editing
  6930. the value of `WaitToKillServiceTimeout' at
  6931. `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control' in the Registry
  6932. tree. Specify the new larger value in milliseconds.  For example, the
  6933. value 120000 tells Windows NT to wait up to 120 seconds.
  6934.  
  6935. If you don't want to start `mysqld' as a service, you can start it from
  6936. the command line.  For instructions, see *Note Win95 start::.
  6937.  
  6938. Please see *Note Windows troubleshooting:: if you encounter
  6939. difficulties during installation.
  6940.  
  6941. Troubleshooting a MySQL Installation Under Windows
  6942. ..................................................
  6943.  
  6944. When installing and running MySQL for the first time, you may encounter
  6945. certain errors that prevent the MySQL server from starting.  The
  6946. purpose of this section is to help you diagnose and correct some of
  6947. these errors.
  6948.  
  6949. Your first resource when troubleshooting server issues is the error log.
  6950. The MySQL server uses the error log to record information relevant to
  6951. the error that is preventing the server from starting. The error log is
  6952. located in the data directory specified in your `my.ini' file.  The
  6953. default data directory location is `C:\mysql\data'.  *Note Error log::.
  6954.  
  6955. Another source of information regarding possible errors is the console
  6956. messages displayed when the MySQL service is starting. Use the `NET
  6957. START mysql' command from the command line after installing `mysqld' as
  6958. a service to see any error messages regarding the starting of the MySQL
  6959. server as a service.  *Note NT start::.
  6960.  
  6961. The following are examples of some of the more common error messages
  6962. you may encounter when installing MySQL and starting the server for the
  6963. first time:
  6964.  
  6965.      System error 1067 has occurred.
  6966.      Fatal error: Can't open privilege tables: Table 'mysql.host' doesn't exist
  6967.  
  6968. These messages occur when the MySQL server cannot find the `mysql'
  6969. privileges database or other critical files. This error is often
  6970. encountered when the MySQL base or data directories are installed in
  6971. different locations than the default locations (`C:\mysql' and
  6972. `C:\mysql\data', respectively).
  6973.  
  6974. If you have installed MySQL to a directory other than `C:\mysql' you
  6975. will need to ensure that the MySQL server is aware of this through the
  6976. use of a configuration (`my.ini') file. The `my.ini' file needs to be
  6977. located in your Windows directory, typically located at `C:\WinNT' or
  6978. `C:\WINDOWS'. You can determine its exact location from the value of
  6979. the `WINDIR' environment variable by issuing the following command from
  6980. the command prompt:
  6981.  
  6982.      C:\> echo %WINDIR%
  6983.  
  6984. An option file can be created and modified with any text editor, such
  6985. as the Notepad program. For example, if MySQL is installed at
  6986. `E:\mysql' and the data directory is located at `D:\MySQLdata', you can
  6987. create the option file and set up a `[mysqld]' section to specify
  6988. values for the basedir and datadir parameters:
  6989.  
  6990.      [mysqld]
  6991.      # set basedir to your installation path
  6992.      basedir=E:/mysql
  6993.      # set datadir to the location of your data directory
  6994.      datadir=D:/MySQLdata
  6995.  
  6996. Note that Windows pathnames are specified in option files using forward
  6997. slashes rather than backslashes. If you do use backslashes, you must
  6998. double them:
  6999.  
  7000.      [mysqld]
  7001.      # set basedir to your installation path
  7002.      basedir=C:\\Program Files\\mysql
  7003.      # set datadir to the location of your data directory
  7004.      datadir=D:\\MySQLdata
  7005. *Note Windows prepare environment::.
  7006.  
  7007. Running MySQL Client Programs on Windows
  7008. ........................................
  7009.  
  7010. You can test whether the MySQL server is working by executing any of the
  7011. following commands:
  7012.  
  7013.      C:\> C:\mysql\bin\mysqlshow
  7014.      C:\> C:\mysql\bin\mysqlshow -u root mysql
  7015.      C:\> C:\mysql\bin\mysqladmin version status proc
  7016.      C:\> C:\mysql\bin\mysql test
  7017.  
  7018. If `mysqld' is slow to respond to TCP/IP connections from client
  7019. programs on Windows 9x/Me, there is probably a problem with your DNS.
  7020. In this case, start `mysqld' with the `--skip-name-resolve' option and
  7021. use only `localhost' and IP numbers in the `Host' column of the MySQL
  7022. grant tables.
  7023.  
  7024. You can force a MySQL client to use a named pipe connection rather than
  7025. TCP/IP  by specifying the `--pipe' option or by specifying `.' (period)
  7026. as the host name.  Use the `--socket' option to specify the name of the
  7027. pipe.  As of MySQL 4.1, you should use the `--protocol=PIPE' option.
  7028.  
  7029. There are two versions of the MySQL command-line tool:
  7030. *Binary*       *Description*
  7031. `mysql'        Compiled on native Windows, offering limited text editing
  7032.                capabilities.
  7033. `mysqlc'       Compiled with the Cygnus GNU compiler and libraries,
  7034.                which offers `readline' editing.
  7035.  
  7036. If you want to use `mysqlc', you must have a copy of the
  7037. `cygwinb19.dll' library installed somewhere that `mysqlc' can find it.
  7038. Current distributions of MySQL include this library in the same
  7039. directory as `mysqlc' (the `bin' directory under the base directory of
  7040. your MySQL installation). If your distribution does not have the
  7041. `cygwinb19.dll' library in the `bin' directory, look for it in the
  7042. `lib' directory and copy it to your Windows system directory
  7043. (`\Windows\system' or a similar place).
  7044.  
  7045. MySQL on Windows Compared to MySQL on Unix
  7046. ..........................................
  7047.  
  7048. MySQL for Windows has by now proven itself to be very stable. The
  7049. Windows version of MySQL has the same features as the corresponding
  7050. Unix version, with the following exceptions:
  7051.  
  7052. *Windows 95 and threads*
  7053.      Windows 95 leaks about 200 bytes of main memory for each thread
  7054.      creation.  Each connection in MySQL creates a new thread, so you
  7055.      shouldn't run `mysqld' for an extended time on Windows 95 if your
  7056.      server handles many connections!  Other versions of Windows don't
  7057.      suffer from this bug.
  7058.  
  7059. *Limited number of ports*
  7060.      Windows systems have about 4,000 ports available for client
  7061.      connections, and after a connection on a port closes, it takes two
  7062.      to four minutes before the port can be reused.  In situations
  7063.      where clients connect to and disconnect from the server at a high
  7064.      rate, it is possible for all available ports to be used up before
  7065.      closed ports become available again. If this happens, the MySQL
  7066.      server will appear to have become unresponsive even though it is
  7067.      running.  Note that ports may be used by other applications
  7068.      running on the machine as well, in which case the number of ports
  7069.      available to MySQL is lower.
  7070.  
  7071.      For more information, see
  7072.      `http://support.microsoft.com/default.aspx?scid=kb;en-us;196271'.
  7073.  
  7074. *Concurrent reads*
  7075.      MySQL depends on the `pread()' and `pwrite()' calls to be able to
  7076.      mix `INSERT' and `SELECT'.  Currently we use mutexes to emulate
  7077.      `pread()'/`pwrite()'.  We will, in the long run, replace the file
  7078.      level interface with a virtual interface so that we can use the
  7079.      `readfile()'/`writefile()' interface on NT, 2000, and XP to get
  7080.      more speed.  The current implementation limits the number of open
  7081.      files MySQL can use to 2,048 (1,024 before MySQL 4.0.19), which
  7082.      means that you will not be able to run as many concurrent threads
  7083.      on NT, 2000, and XP as on Unix.
  7084.  
  7085. *Blocking read*
  7086.      MySQL uses a blocking read for each connection, which has the
  7087.      following implications if named pipe connections are enabled:
  7088.  
  7089.         * A connection will not be disconnected automatically after
  7090.           eight hours, as happens with the Unix version of MySQL.
  7091.  
  7092.         * If a connection hangs, it's impossible to break it without
  7093.           killing MySQL.
  7094.  
  7095.         * `mysqladmin kill' will not work on a sleeping connection.
  7096.  
  7097.         * `mysqladmin shutdown' can't abort as long as there are
  7098.           sleeping connections.
  7099.  
  7100.      We plan to fix this problem when our Windows developers have
  7101.      figured out a nice workaround.
  7102.  
  7103. *`ALTER TABLE'*
  7104.      While you are executing an `ALTER TABLE' statement, the table is
  7105.      locked from being used by other threads.  This has to do with the
  7106.      fact that on Windows, you can't delete a file that is in use by
  7107.      another thread.  In the future, we may find some way to work
  7108.      around this problem.
  7109.  
  7110. *`DROP TABLE'*
  7111.      `DROP TABLE' on a table that is in use by a `MERGE' table will not
  7112.      work on Windows because the `MERGE' handler does the table mapping
  7113.      hidden from the upper layer of MySQL.  Because Windows doesn't
  7114.      allow you to drop files that are open, you first must flush all
  7115.      `MERGE' tables (with `FLUSH TABLES') or drop the `MERGE' table
  7116.      before dropping the table.  We will fix this at the same time we
  7117.      introduce views.
  7118.  
  7119. *`DATA DIRECTORY' and `INDEX DIRECTORY'*
  7120.      The `DATA DIRECTORY' and `INDEX DIRECTORY' options for `CREATE
  7121.      TABLE' are ignored on Windows, because Windows doesn't support
  7122.      symbolic links.  These options also are ignored on systems that
  7123.      have a non-functional `realpath()' call.
  7124.  
  7125. *`DROP DATABASE'*
  7126.      You cannot drop a database that is in use by some thread.
  7127.  
  7128. *Killing MySQL from the Task Manager*
  7129.      You cannot kill MySQL from the Task Manager or with the shutdown
  7130.      utility in Windows 95.  You must take it down with `mysqladmin
  7131.      shutdown'.
  7132.  
  7133. *Case-insensitive names*
  7134.      Filenames are not case sensitive on Windows, so MySQL database and
  7135.      table names are also not case sensitive on Windows.  The only
  7136.      restriction is that database and table names must be specified
  7137.      using the same case throughout a given statement.  *Note Name case
  7138.      sensitivity::.
  7139.  
  7140. *The `\' pathname separator character*
  7141.      Pathname components in Windows 95 are separated by the `\'
  7142.      character, which is also the escape character in MySQL.  If you
  7143.      are using `LOAD DATA INFILE' or `SELECT ... INTO OUTFILE', use
  7144.      Unix-style filenames with `/' characters:
  7145.  
  7146.           mysql> LOAD DATA INFILE 'C:/tmp/skr.txt' INTO TABLE skr;
  7147.           mysql> SELECT * INTO OUTFILE 'C:/tmp/skr.txt' FROM skr;
  7148.  
  7149.      Alternatively, you must double the `\' character:
  7150.  
  7151.           mysql> LOAD DATA INFILE 'C:\\tmp\\skr.txt' INTO TABLE skr;
  7152.           mysql> SELECT * INTO OUTFILE 'C:\\tmp\\skr.txt' FROM skr;
  7153.  
  7154. *Problems with pipes.*
  7155.      Pipes do not work reliably from the Windows command-line prompt.
  7156.      If the pipe includes the character `^Z' / `CHAR(24)', Windows will
  7157.      think it has encountered end-of-file and abort the program.
  7158.  
  7159.      This is mainly a problem when you try to apply a binary log as
  7160.      follows:
  7161.  
  7162.           C:\> mysqlbinlog binary-log-name | mysql --user=root
  7163.  
  7164.      If you have a problem applying the log and suspect that it is
  7165.      because of a `^Z' / `CHAR(24)' character, you can use the
  7166.      following workaround:
  7167.  
  7168.           C:\> mysqlbinlog binary-log-file --result-file=/tmp/bin.sql
  7169.           C:\> mysql --user=root --execute "source /tmp/bin.sql"
  7170.  
  7171.      The latter command also can be used to reliably read in any SQL
  7172.      file that may contain binary data.
  7173.  
  7174. *`Can't open named pipe' error*
  7175.      If you use a MySQL 3.22 server on Windows NT with the newest MySQL
  7176.      client programs, you will get the following error:
  7177.  
  7178.           error 2017: can't open named pipe to host: . pipe...
  7179.  
  7180.      This happens because the release version of MySQL uses named pipes
  7181.      on NT by default.  You can avoid this error by using the
  7182.      `--host=localhost' option to the new MySQL clients or by creating
  7183.      an option file `C:\my.cnf' that contains the following information:
  7184.  
  7185.           [client]
  7186.           host = localhost
  7187.  
  7188.      Starting from 3.23.50, named pipes are enabled only if `mysqld-nt'
  7189.      or `mysqld-max-nt' is started with `--enable-named-pipe'.
  7190.  
  7191. *`Access denied for user' error*
  7192.      If you attempt to run a MySQL client program to connect to a server
  7193.      running on the same machine, but get the error `Access denied for
  7194.      user 'SOME-USER'@'unknown' to database 'mysql'', this means that
  7195.      MySQL cannot resolve your hostname properly.
  7196.  
  7197.      To fix this, you should create a file named `\windows\hosts'
  7198.      containing the following information:
  7199.  
  7200.           127.0.0.1       localhost
  7201.  
  7202. Here are some open issues for anyone who might want to help us improve
  7203. MySQL on Windows:
  7204.  
  7205.    * Add some nice start and shutdown icons to the MySQL installation.
  7206.  
  7207.    * It would be really nice to be able to kill `mysqld' from the Task
  7208.      Manager in Windows 95.  For the moment, you must use `mysqladmin
  7209.      shutdown'.
  7210.  
  7211.    * Port `readline' to Windows for use in the `mysql' command-line
  7212.      tool.
  7213.  
  7214.    * GUI versions of the standard MySQL clients (`mysql', `mysqlshow',
  7215.      `mysqladmin', and `mysqldump') would be nice.
  7216.  
  7217.    * It would be nice if the socket read and write functions in `net.c'
  7218.      were interruptible. This would make it possible to kill open
  7219.      threads with `mysqladmin kill' on Windows.
  7220.  
  7221.    * Add macros to use the faster thread-safe increment/decrement
  7222.      methods provided by Windows.
  7223.  
  7224. Installing MySQL on Linux
  7225. -------------------------
  7226.  
  7227. The recommended way to install MySQL on Linux is by using the RPM
  7228. packages. The MySQL RPMs are currently built on a SuSE Linux 7.3
  7229. system, but should work on most versions of Linux that support `rpm'
  7230. and use `glibc'.  To obtain RPM packages, see *Note Getting MySQL::.
  7231.  
  7232. *Note*: RPM distributions of MySQL often are provided by other vendors.
  7233. Be aware that they may differ in features and capabilities from those
  7234. built by MySQL AB, and that the instructions in this manual do not
  7235. necessarily apply to installing them. The vendor's instructions should
  7236. be consulted instead.
  7237.  
  7238. If you have problems with an RPM file (for example, if you receive the
  7239. error "`Sorry, the host 'XXXX' could not be looked up'"), see *Note
  7240. Binary notes-Linux::.
  7241.  
  7242. In most cases, you only need to install the `MySQL-server' and
  7243. `MySQL-client' packages to get a functional MySQL installation. The
  7244. other packages are not required for a standard installation.  If you
  7245. want to run a MySQL-Max server that has additional capabilities, you
  7246. should also install the `MySQL-Max' RPM. However, you should do so only
  7247. _ after_ installing the `MySQL-server' RPM.  *Note `mysqld-max':
  7248. mysqld-max.
  7249.  
  7250. If you get a dependency failure when trying to install the MySQL 4.0
  7251. packages (for example, "`error: removing these packages would break
  7252. dependencies: libmysqlclient.so.10 is needed by ...'"), you should also
  7253. install the package `MySQL-shared-compat', which includes both the
  7254. shared libraries for backward compatibility (`libmysqlclient.so.12' for
  7255. MySQL 4.0 and `libmysqlclient.so.10' for MySQL 3.23).
  7256.  
  7257. Many Linux distributions still ship with MySQL 3.23 and they usually
  7258. link applications dynamically to save disk space. If these shared
  7259. libraries are in a separate package (for example, `MySQL-shared'), it is
  7260. sufficient to simply leave this package installed and just upgrade the
  7261. MySQL server and client packages (which are statically linked and do
  7262. not depend on the shared libraries). For distributions that include the
  7263. shared libraries in the same package as the MySQL server (for example,
  7264. Red Hat Linux), you could either install our 3.23 `MySQL-shared' RPM,
  7265. or use the `MySQL-shared-compat' package instead.
  7266.  
  7267. The following RPM packages are available:
  7268.  
  7269.    * `MySQL-server-VERSION.i386.rpm'
  7270.  
  7271.      The MySQL server.  You will need this unless you only want to
  7272.      connect to a MySQL server running on another machine. Note: Server
  7273.      RPM files were called `MySQL-VERSION.i386.rpm' before MySQL
  7274.      4.0.10. That is, they did not have `-server' in the name.
  7275.  
  7276.    * `MySQL-Max-VERSION.i386.rpm'
  7277.  
  7278.      The MySQL-Max server. This server has additional capabilities that
  7279.      the one provided in the `MySQL-server' RPM does not.  You must
  7280.      install the `MySQL-server' RPM first, because the `MySQL-Max' RPM
  7281.      depends on it.
  7282.  
  7283.    * `MySQL-client-VERSION.i386.rpm'
  7284.  
  7285.      The standard MySQL client programs. You probably always want to
  7286.      install this package.
  7287.  
  7288.    * `MySQL-bench-VERSION.i386.rpm'
  7289.  
  7290.      Tests and benchmarks. Requires Perl and the `DBD::mysql' module.
  7291.  
  7292.    * `MySQL-devel-VERSION.i386.rpm'
  7293.  
  7294.      The libraries and include files that are needed if you want to
  7295.      compile other MySQL clients, such as the Perl modules.
  7296.  
  7297.    * `MySQL-shared-VERSION.i386.rpm'
  7298.  
  7299.      This package contains the shared libraries (`libmysqlclient.so*')
  7300.      that certain languages and applications need to dynamically load
  7301.      and use MySQL.
  7302.  
  7303.    * `MySQL-shared-compat-VERSION.i386.rpm'
  7304.  
  7305.      This package includes the shared libraries for both MySQL 3.23 and
  7306.      MySQL 4.0. Install this package instead of `MySQL-shared' if you
  7307.      have applications installed that are dynamically linked against
  7308.      MySQL 3.23 but you want to upgrade to MySQL 4.0 without breaking
  7309.      the library dependencies. This package has been available since
  7310.      MySQL 4.0.13.
  7311.  
  7312.    * `MySQL-embedded-VERSION.i386.rpm'
  7313.  
  7314.      The embedded MySQL server library (from MySQL 4.0).
  7315.  
  7316.    * `MySQL-VERSION.src.rpm'
  7317.  
  7318.      This contains the source code for all of the previous packages. It
  7319.      can also be used to rebuild the RPMs on other architectures (for
  7320.      example, Alpha or SPARC).
  7321.  
  7322. To see all files in an RPM package (for example, a `MySQL-server' RPM),
  7323. run:
  7324.  
  7325.      shell> rpm -qpl MySQL-server-VERSION.i386.rpm
  7326.  
  7327. To perform a standard minimal installation, run:
  7328.  
  7329.      shell> rpm -i MySQL-server-VERSION.i386.rpm
  7330.      shell> rpm -i MySQL-client-VERSION.i386.rpm
  7331.  
  7332. To install just the client package, run:
  7333.  
  7334.      shell> rpm -i MySQL-client-VERSION.i386.rpm
  7335.  
  7336. RPM provides a feature to verify the integrity and authenticity of
  7337. packages before installing them. If you would like to learn more about
  7338. this feature, see *Note Verifying Package Integrity::.
  7339.  
  7340. The server RPM places data under the `/var/lib/mysql' directory. The
  7341. RPM also creates a login account for a user named `mysql' (if one does
  7342. not already exist) to use for running the MySQL server, and creates the
  7343. appropriate entries in `/etc/init.d/' to start the server automatically
  7344. at boot time. (This means that if you have performed a previous
  7345. installation and have made changes to its startup script, you may want
  7346. to make a copy of the script so that you don't lose it when you install
  7347. a newer RPM.) See *Note Automatic start:: for more information on how
  7348. MySQL can be started automatically on system startup.
  7349.  
  7350. If you want to install the MySQL RPM on older Linux distributions that
  7351. do not support initialization scripts in `/etc/init.d' (directly or via
  7352. a symlink), you should create a symbolic link that points to the
  7353. location where your initialization scripts actually are installed. For
  7354. example, if that location is `/etc/rc.d/init.d', use these commands
  7355. before installing the RPM to create `/etc/init.d' as a symbolic link
  7356. that points there:
  7357.  
  7358.      shell> cd /etc
  7359.      shell> ln -s rc.d/init.d .
  7360.  
  7361. However, all current major Linux distributions should already support
  7362. the new directory layout that uses `/etc/init.d', because it is
  7363. required for LSB (Linux Standard Base) compliance.
  7364.  
  7365. If the RPM files that you install include `MySQL-server', the `mysqld'
  7366. server should be up and running after installation.  You should now be
  7367. able to start using MySQL.
  7368.  
  7369. If something goes wrong, you can find more information in the binary
  7370. installation section. *Note Installing binary::.
  7371.  
  7372. *Note*: The accounts that are listed in the MySQL grant tables
  7373. initially have no passwords.  After starting the server, you should set
  7374. up passwords for them using the instructions in *Note
  7375. Post-installation::.
  7376.  
  7377. Installing MySQL on Mac OS X
  7378. ----------------------------
  7379.  
  7380. Beginning with MySQL 4.0.11, you can install MySQL on Mac OS X 10.2.x
  7381. ("Jaguar") and up using a Mac OS X binary package in PKG format instead
  7382. of the binary tarball distribution. Please note that older versions of
  7383. Mac OS X (for example, 10.1.x) are not supported by this package.
  7384.  
  7385. The package is located inside a disk image (`.dmg') file that you first
  7386. need to mount by double-clicking its icon in the Finder. It should then
  7387. mount the image and display its contents.
  7388.  
  7389. To obtain MySQL, see *Note Getting MySQL::.
  7390.  
  7391. *Note*: Before proceeding with the installation, be sure to shut down
  7392. all running MySQL server instances by either using the MySQL Manager
  7393. Application (on Mac OS X Server) or via `mysqladmin shutdown' on the
  7394. command line.
  7395.  
  7396. To actually install the MySQL PKG file, double-click on the package
  7397. icon. This launches the Mac OS X Package Installer, which will guide
  7398. you through the installation of MySQL.
  7399.  
  7400. Due to a bug in the Mac OS X package installer, you may see this error
  7401. message in the destination disk selection dialog:
  7402.  
  7403.      You cannot install this software on this disk. (null)
  7404.  
  7405. If this error occurs, simply click the `Go Back' button once to return
  7406. to the previous screen. Then click `Continue' to advance to the
  7407. destination disk selection again, and you should be able to choose the
  7408. destination disk correctly. We have reported this bug to Apple and it is
  7409. investigating this problem.
  7410.  
  7411. The Mac OS X PKG of MySQL will install itself into
  7412. `/usr/local/mysql-VERSION' and will also install a symbolic link,
  7413. `/usr/local/mysql', pointing to the new location. If a directory named
  7414. `/usr/local/mysql' already exists, it will be renamed to
  7415. `/usr/local/mysql.bak' first. Additionally, the installer will create
  7416. the grant tables in the `mysql' database by executing `mysql_install_db'
  7417. after the installation.
  7418.  
  7419. The installation layout is similar to that of a `tar' file binary
  7420. distribution; all MySQL binaries are located in the directory
  7421. `/usr/local/mysql/bin'.  The MySQL socket file is created as
  7422. `/tmp/mysql.sock' by default.  *Note Installation layouts::.
  7423.  
  7424. MySQL installation requires a Mac OS X user account named `mysql'.  A
  7425. user account with this name should exist by default on Mac OS X 10.2
  7426. and up.
  7427.  
  7428. If you are running Mac OS X Server, you already have a version of MySQL
  7429. installed.  The versions of MySQL that ship with Mac OS X Server
  7430. versions are shown in the following table:
  7431.  
  7432. *Mac OS X Server       *MySQL Version*
  7433. Version*               
  7434. 10.2-10.2.2            3.23.51
  7435. 10.2.3-10.2.6          3.23.53
  7436. 10.3                   4.0.14
  7437. 10.3.2                 4.0.16
  7438.  
  7439. This manual section covers the installation of the official MySQL Mac
  7440. OS X PKG only.  Make sure to read Apple's help information about
  7441. installing MySQL: Run the "Help View" application, select "Mac OS X
  7442. Server" help, do a search for "MySQL," and read the item entitled
  7443. "Installing MySQL."
  7444.  
  7445. For pre-installed versions of MySQL on Mac OS X Server, note especially
  7446. that you should start `mysqld' with `safe_mysqld' instead of
  7447. `mysqld_safe' if MySQL is older than version 4.0.
  7448.  
  7449. If you previously used Marc Liyanage's MySQL packages for Mac OS X from
  7450. `http://www.entropy.ch', you can simply follow the update instructions
  7451. for packages using the binary installation layout as given on his pages.
  7452.  
  7453. If you are upgrading from Marc's 3.23.xx versions or from the Mac OS X
  7454. Server version of MySQL to the official MySQL PKG, you also need to
  7455. convert the existing MySQL privilege tables to the current format,
  7456. because some new security privileges have been added.  *Note
  7457. Upgrading-grant-tables::.
  7458.  
  7459. If you would like to automatically start up MySQL during system
  7460. startup, you also need to install the MySQL Startup Item. Starting with
  7461. MySQL 4.0.15, it is part of the Mac OS X installation disk images as a
  7462. separate installation package. Simply double-click the
  7463. `MySQLStartupItem.pkg' icon and follow the instructions to install it.
  7464.  
  7465. Note that the Startup Item need be installed only once! There is no
  7466. need to install it each time you upgrade the MySQL package later.
  7467.  
  7468. The Startup Item will be installed into
  7469. `/Library/StartupItems/MySQLCOM'.  (Before MySQL 4.1.2, the location
  7470. was `/Library/StartupItems/MySQL', but that collided with the MySQL
  7471. Startup Item installed by Mac OS X Server.)  Startup Item installation
  7472. adds a variable `MYSQLCOM=-YES-' to the system configuration file
  7473. `/etc/hostconfig'. If you would like to disable the automatic startup
  7474. of MySQL, simply change this variable to `MYSQLCOM=-NO-'.
  7475.  
  7476. On Mac OS X Server, the default MySQL installation uses the variable
  7477. `MYSQL' in the `/etc/hostconfig' file.  The MySQL AB Startup Item
  7478. installer disables this variable by setting it to `MYSQL=-NO-'. This
  7479. avoids boot time conflicts with the `MYSQLCOM' variable used by the
  7480. MySQL AB Startup Item.  However, it does not shut down an already
  7481. running MySQL server. You should do that yourself.
  7482.  
  7483. After the installation, you can start up MySQL by running the following
  7484. commands in a terminal window. You must have administrator privileges to
  7485. perform this task.
  7486.  
  7487. If you have installed the Startup Item:
  7488.  
  7489.      shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
  7490.      (Enter your password, if necessary)
  7491.      (Press Control-D or enter "exit" to exit the shell)
  7492.  
  7493. For versions of MySQL older than 4.1.3, substitute
  7494. `/Library/StartupItems/MySQLCOM/MySQLCOM' with
  7495. `/Library/StartupItems/MySQL/MySQL' above.
  7496.  
  7497. If you don't use the Startup Item, enter the following command sequence:
  7498.  
  7499.      shell> cd /usr/local/mysql
  7500.      shell> sudo ./bin/mysqld_safe
  7501.      (Enter your password, if necessary)
  7502.      (Press Control-Z)
  7503.      shell> bg
  7504.      (Press Control-D or enter "exit" to exit the shell)
  7505.  
  7506. You should now be able to connect to the MySQL server, for example, by
  7507. running `/usr/local/mysql/bin/mysql'.
  7508.  
  7509. *Note*: The accounts that are listed in the MySQL grant tables
  7510. initially have no passwords.  After starting the server, you should set
  7511. up passwords for them using the instructions in *Note
  7512. Post-installation::.
  7513.  
  7514. You might want to add aliases to your shell's resource file to make it
  7515. easier to access commonly used programs such as `mysql' and `mysqladmin'
  7516. from the command line. The syntax for `tcsh' is:
  7517.  
  7518.      alias mysql /usr/local/mysql/bin/mysql
  7519.      alias mysqladmin /usr/local/mysql/bin/mysqladmin
  7520.  
  7521. For `bash', use:
  7522.  
  7523.      alias mysql=/usr/local/mysql/bin/mysql
  7524.      alias mysqladmin=/usr/local/mysql/bin/mysqladmin
  7525.  
  7526. Even better, add `/usr/local/mysql/bin' to your `PATH' environment
  7527. variable. For example, add the following line to your `$HOME/.tcshrc'
  7528. file if your shell is `tcsh':
  7529.  
  7530.      setenv PATH ${PATH}:/usr/local/mysql/bin
  7531.  
  7532. If no `.tcshrc' file exists in your home directory, create it with a
  7533. text editor.
  7534.  
  7535. If you are upgrading an existing installation, please note that
  7536. installing a new MySQL PKG does not remove the directory of an older
  7537. installation. Unfortunately, the Mac OS X Installer does not yet offer
  7538. the functionality required to properly upgrade previously installed
  7539. packages.
  7540.  
  7541. To use your existing databases with the new installation, you'll need
  7542. to copy the contents of the old data directory to the new data
  7543. directory. Make sure that neither the old server nor the new one is
  7544. running when you do this.  After you have copied over the MySQL
  7545. database files from the previous installation and have successfully
  7546. started the new server, you should consider removing the old
  7547. installation files to save disk space.  Additionally, you should also
  7548. remove older versions of the Package Receipt directories located in
  7549. `/Library/Receipts/mysql-VERSION.pkg'.
  7550.  
  7551. Installing MySQL on NetWare
  7552. ---------------------------
  7553.  
  7554. Porting MySQL to NetWare was an effort spearheaded by Novell. Novell
  7555. customers will be pleased to note that NetWare 6.5 ships with bundled
  7556. MySQL binaries, complete with an automatic commercial use license for
  7557. all servers running that version of NetWare.
  7558.  
  7559. MySQL for NetWare is compiled using a combination of `Metrowerks
  7560. CodeWarrior for NetWare' and special cross-compilation versions of the
  7561. GNU autotools.
  7562.  
  7563. The latest binary packages for NetWare can be obtained at
  7564. `http://dev.mysql.com/downloads/'.  *Note Getting MySQL::.
  7565.  
  7566. In order to host MySQL, the NetWare server must meet these requirements:
  7567.  
  7568.    * NetWare 6.5 Support Pack 2 installed and updated with the latest
  7569.      LibC, or NetWare 6.0 with Support Pack 4 installed and updated
  7570.      with the latest LibC.  NetWare 6.5 Support Pack 2 and other
  7571.      updates are available at
  7572.      `http://support.novell.com/filefinder/18197/index.html'.  NetWare
  7573.      6.0 Support Pack 4 and other updates are available at
  7574.      `http://support.novell.com/filefinder/13659/index.html'.  The
  7575.      latest LibC is available at
  7576.      `http://developer.novell.com/ndk/libc.htm'.  Steps to update LibC
  7577.      can be found here:
  7578.      `http://developer.novell.com/ndk/doc/libc/index.html?page=/ndk/doc/libc/libc_enu/data/ajjl0r0.html'
  7579.  
  7580.    * The system must meet Novell's minimum requirements to run the
  7581.      respective version of NetWare.
  7582.  
  7583.    * MySQL data, as well as the binaries themselves, must be installed
  7584.      on an NSS volume; traditional volumes are not supported.
  7585.  
  7586. To install MySQL for NetWare, use the following procedure:
  7587.  
  7588.   1. If you are upgrading from a prior installation, stop the MySQL
  7589.      server.  This is done from the server console, using the following
  7590.      command:
  7591.  
  7592.           SERVER:  mysqladmin -u root shutdown
  7593.  
  7594.   2. Log on to the target server from a client machine with access to
  7595.      the location where you will install MySQL.
  7596.  
  7597.   3. Extract the binary package Zip file onto the server. Be sure to
  7598.      allow the paths in the Zip file to be used. It is safe to simply
  7599.      extract the file to `SYS:\'.
  7600.  
  7601.      If you are upgrading from a prior installation, you may need to
  7602.      copy the data directory (for example, `SYS:MYSQL\DATA') now, as
  7603.      well as `my.cnf', if you have customized it. You can then delete
  7604.      the old copy of MySQL.
  7605.  
  7606.   4. You might want to rename the directory to something more
  7607.      consistent and easy to use. We recommend using `SYS:MYSQL';
  7608.      examples in this manual use this name to refer to the installation
  7609.      directory in general.
  7610.  
  7611.   5. At the server console, add a search path for the directory
  7612.      containing the MySQL NLMs. For example:
  7613.  
  7614.           SERVER:  SEARCH ADD SYS:MYSQL\BIN
  7615.  
  7616.   6. Initialize the data directory and the grant tables, if needed, by
  7617.      executing `mysql_install_db' at the server console.
  7618.  
  7619.   7. Start the MySQL server using `mysqld_safe' at the server console.
  7620.  
  7621.   8. To finish the installation, you should also add the following
  7622.      commands to `autoexec.ncf'. For example, if your MySQL
  7623.      installation is in `SYS:MYSQL' and you want MySQL to start
  7624.      automatically, you could add these lines:
  7625.  
  7626.           #Starts the MySQL 4.0.x database server
  7627.           SEARCH ADD SYS:MYSQL\BIN
  7628.           MYSQLD_SAFE
  7629.  
  7630.      If you are running MySQL on NetWare 6.0, we strongly suggest that
  7631.      you use the `--skip-external-locking' option on the command line:
  7632.  
  7633.           #Starts the MySQL 4.0.x database server
  7634.           SEARCH ADD SYS:MYSQL\BIN
  7635.           MYSQLD_SAFE --skip-external-locking
  7636.  
  7637.      It will also be necessary to use `CHECK TABLE' and `REPAIR TABLE'
  7638.      instead of `myisamchk', because `myisamchk' makes use of external
  7639.      locking.  External locking is known to have problems on NetWare
  7640.      6.0; the problem has been eliminated in NetWare 6.5.
  7641.  
  7642.      `mysqld_safe' on NetWare provides a screen presence. When you
  7643.      unload (shut down) the `mysqld_safe' NLM, the screen does not by
  7644.      default go away.  Instead, it prompts for user input:
  7645.  
  7646.           *<NLM has terminated; Press any key to close the screen>*
  7647.  
  7648.      If you want NetWare to close the screen automatically instead, use
  7649.      the `--autoclose' option to `mysqld_safe'. For example:
  7650.  
  7651.           #Starts the MySQL 4.0.x database server
  7652.           SEARCH ADD SYS:MYSQL\BIN
  7653.           MYSQLD_SAFE --autoclose
  7654.  
  7655.   9. The latest Netware Perl and PHP modules for MySQL can be
  7656.      downloaded from `http://developer.novell.com/ndk/perl5.htm' and
  7657.      `http://developer.novell.com/ndk/php2.htm' respectively.
  7658.  
  7659.  
  7660. The behavior of `mysqld_safe' on NetWare is described further in *Note
  7661. `mysqld_safe': mysqld_safe.
  7662.  
  7663. If there was an existing installation of MySQL on the server, be sure
  7664. to check for existing MySQL startup commands in `autoexec.ncf', and
  7665. edit or delete them as necessary.
  7666.  
  7667. *Note*: The accounts that are listed in the MySQL grant tables
  7668. initially have no passwords.  After starting the server, you should set
  7669. up passwords for them using the instructions in *Note
  7670. Post-installation::.
  7671.  
  7672. Installing MySQL on Other Unix-Like Systems
  7673. -------------------------------------------
  7674.  
  7675. This section covers the installation of MySQL binary distributions that
  7676. are provided for various platforms in the form of compressed `tar' files
  7677. (files with a `.tar.gz' extension).  See *Note MySQL binaries:: for a
  7678. detailed list.
  7679.  
  7680. To obtain MySQL, see *Note Getting MySQL::.
  7681.  
  7682. MySQL `tar' file binary distributions have names of the form
  7683. `mysql-VERSION-OS.tar.gz', where `VERSION' is a number (for example,
  7684. `4.0.17'), and OS indicates the type of operating system for which the
  7685. distribution is intended (for example, `pc-linux-i686').
  7686.  
  7687. In addition to these generic packages, we also offer binaries in
  7688. platform-specific package formats for selected platforms.  See *Note
  7689. Quick Standard Installation:: for more information on how to install
  7690. these.
  7691.  
  7692. You need the following tools to install a MySQL `tar' file binary
  7693. distribution:
  7694.  
  7695.    * GNU `gunzip' to uncompress the distribution.
  7696.  
  7697.    * A reasonable `tar' to unpack the distribution. GNU `tar' is known
  7698.      to work. Some operating systems come with a pre-installed version
  7699.      of `tar' that is known to have problems.  For example, Mac OS X
  7700.      `tar' and Sun `tar' are known to have problems with long
  7701.      filenames.  On Mac OS X, you can use the pre-installed `gnutar'
  7702.      program.  On other systems with a deficient `tar', you should
  7703.      install GNU `tar' first.
  7704.  
  7705. If you run into problems, _please always use `mysqlbug'_ when posting
  7706. questions to a MySQL mailing list.  Even if the problem isn't a bug,
  7707. `mysqlbug' gathers system information that will help others solve your
  7708. problem.  By not using `mysqlbug', you lessen the likelihood of getting
  7709. a solution to your problem.  You will find `mysqlbug' in the `bin'
  7710. directory after you unpack the distribution.  *Note Bug reports::.
  7711.  
  7712. The basic commands you must execute to install and use a MySQL binary
  7713. distribution are:
  7714.  
  7715.      shell> groupadd mysql
  7716.      shell> useradd -g mysql mysql
  7717.      shell> cd /usr/local
  7718.      shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
  7719.      shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
  7720.      shell> cd mysql
  7721.      shell> scripts/mysql_install_db --user=mysql
  7722.      shell> chown -R root  .
  7723.      shell> chown -R mysql data
  7724.      shell> chgrp -R mysql .
  7725.      shell> bin/mysqld_safe --user=mysql &
  7726.  
  7727. For versions of MySQL older than 4.0, substitute `bin/safe_mysqld' for
  7728. `bin/mysqld_safe' in the final command.
  7729.  
  7730. *Note*: This procedure does not set up any passwords for MySQL
  7731. accounts.  After following the procedure, proceed to *Note
  7732. Post-installation::.
  7733.  
  7734. A more detailed version of the preceding description for installing a
  7735. binary distribution follows:
  7736.  
  7737.   1. Add a login user and group for `mysqld' to run as:
  7738.  
  7739.           shell> groupadd mysql
  7740.           shell> useradd -g mysql mysql
  7741.  
  7742.      These commands add the `mysql' group and the `mysql' user.  The
  7743.      syntax for `useradd' and `groupadd' may differ slightly on
  7744.      different versions of Unix.  They may also be called `adduser' and
  7745.      `addgroup'.
  7746.  
  7747.      You might want to call the user and group something else instead
  7748.      of `mysql'.  If so, substitute the appropriate name in the
  7749.      following steps.
  7750.  
  7751.   2. Pick the directory under which you want to unpack the
  7752.      distribution, and change location into it. In the following
  7753.      example, we unpack the distribution under `/usr/local'. (The
  7754.      instructions, therefore, assume that you have permission to create
  7755.      files and directories in `/usr/local'.  If that directory is
  7756.      protected, you will need to perform the installation as `root'.)
  7757.  
  7758.           shell> cd /usr/local
  7759.  
  7760.   3. Obtain a distribution file from one of the sites listed in *Note
  7761.      Getting MySQL: Getting MySQL.  For a given release, binary
  7762.      distributions for all platforms are built from the same MySQL
  7763.      source distribution.
  7764.  
  7765.   4. Unpack the distribution, which will create the installation
  7766.      directory.  Then create a symbolic link to that directory:
  7767.  
  7768.           shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
  7769.           shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
  7770.  
  7771.      The `tar' command creates a directory named `mysql-VERSION-OS'.
  7772.      The `ln' command makes a symbolic link to that directory.  This
  7773.      lets you refer more easily to the installation directory as
  7774.      `/usr/local/mysql'.
  7775.  
  7776.      With GNU `tar', no separate invocation of `gunzip' is necessary.
  7777.      You can replace the first line with the following alternative
  7778.      command to uncompress and extract the distribution:
  7779.  
  7780.           shell> tar zxvf /PATH/TO/MYSQL-VERSION-OS.tar.gz
  7781.  
  7782.   5. Change location into the installation directory:
  7783.  
  7784.           shell> cd mysql
  7785.  
  7786.      You will find several files and subdirectories in the `mysql'
  7787.      directory.  The most important for installation purposes are the
  7788.      `bin' and `scripts' subdirectories.
  7789.  
  7790.     `bin'
  7791.           This directory contains client programs and the server.  You
  7792.           should add the full pathname of this directory to your `PATH'
  7793.           environment variable so that your shell finds the MySQL
  7794.           programs properly. *Note Environment variables::.
  7795.  
  7796.     `scripts'
  7797.           This directory contains the `mysql_install_db' script used to
  7798.           initialize the `mysql' database containing the grant tables
  7799.           that store the server access permissions.
  7800.  
  7801.   6. If you haven't installed MySQL before, you must create the MySQL
  7802.      grant tables:
  7803.  
  7804.           shell> scripts/mysql_install_db --user=mysql
  7805.  
  7806.      If you run the command as `root', you should use the `--user'
  7807.      option as shown.  The value of the option should be the name of
  7808.      the login account that you created in the first step to use for
  7809.      running the server.  If you run the command while logged in as
  7810.      that user, you can omit the `--user' option.
  7811.  
  7812.      Note that for MySQL versions older than 3.22.10,
  7813.      `mysql_install_db' left the server running after creating the grant
  7814.      tables.  This is no longer true; you will need to restart the
  7815.      server after performing the remaining steps in this procedure.
  7816.  
  7817.   7. Change the ownership of program binaries to `root' and ownership
  7818.      of the data directory to the user that you will run `mysqld' as.
  7819.      Assuming that you are located in the installation directory
  7820.      (`/usr/local/mysql'), the commands look like this:
  7821.  
  7822.           shell> chown -R root  .
  7823.           shell> chown -R mysql data
  7824.           shell> chgrp -R mysql .
  7825.  
  7826.      The first command changes the owner attribute of the files to the
  7827.      `root' user. The second changes the owner attribute of the data
  7828.      directory to the `mysql' user. The third changes the group
  7829.      attribute to the `mysql' group.
  7830.  
  7831.   8. If you would like MySQL to start automatically when you boot your
  7832.      machine, you can copy `support-files/mysql.server' to the location
  7833.      where your system has its startup files.  More information can be
  7834.      found in the `support-files/mysql.server' script itself and in
  7835.      *Note Automatic start::.
  7836.  
  7837.   9. You can set up new accounts using the `bin/mysql_setpermission'
  7838.      script if you install the `DBI' and `DBD::mysql' Perl modules.
  7839.      For instructions, see *Note Perl support::.
  7840.  
  7841.  10. If you would like to use `mysqlaccess' and have the MySQL
  7842.      distribution in some non-standard place, you must change the
  7843.      location where `mysqlaccess' expects to find the `mysql' client.
  7844.      Edit the `bin/mysqlaccess' script at approximately line 18.
  7845.      Search for a line that looks like this:
  7846.  
  7847.           $MYSQL     = '/usr/local/bin/mysql';    # path to mysql executable
  7848.  
  7849.      Change the path to reflect the location where `mysql' actually is
  7850.      stored on your system.  If you do not do this, you will get a
  7851.      `Broken pipe' error when you run `mysqlaccess'.
  7852.  
  7853.  
  7854. After everything has been unpacked and installed, you should test your
  7855. distribution.
  7856.  
  7857. You can start the MySQL server with the following command:
  7858.  
  7859.      shell> bin/mysqld_safe --user=mysql &
  7860.  
  7861. For versions of MySQL older than 4.0, substitute `bin/safe_mysqld' for
  7862. `bin/mysqld_safe' in the command.
  7863.  
  7864. More information about `mysqld_safe' is given in *Note `mysqld_safe':
  7865. mysqld_safe.
  7866.  
  7867. *Note*: The accounts that are listed in the MySQL grant tables
  7868. initially have no passwords.  After starting the server, you should set
  7869. up passwords for them using the instructions in *Note
  7870. Post-installation::.
  7871.  
  7872. MySQL Installation Using a Source Distribution
  7873. ==============================================
  7874.  
  7875. Before you proceed with the source installation, check first to see
  7876. whether our binary is available for your platform and whether it will
  7877. work for you. We put a lot of effort into making sure that our binaries
  7878. are built with the best possible options.
  7879.  
  7880. To obtain a source distribution for MySQL, *Note Getting MySQL::.
  7881.  
  7882. MySQL source distributions are provided as compressed `tar' archives
  7883. and have names of the form `mysql-VERSION.tar.gz', where VERSION is a
  7884. number like `4.0.22'.
  7885.  
  7886. You need the following tools to build and install MySQL from source:
  7887.  
  7888.    * GNU `gunzip' to uncompress the distribution.
  7889.  
  7890.    * A reasonable `tar' to unpack the distribution. GNU `tar' is known
  7891.      to work. Some operating systems come with a pre-installed version
  7892.      of `tar' that is known to have problems.  For example, Mac OS X
  7893.      `tar' and Sun `tar' are known to have problems with long
  7894.      filenames.  On Mac OS X, you can use the pre-installed `gnutar'
  7895.      program.  On other systems with a deficient `tar', you should
  7896.      install GNU `tar' first.
  7897.  
  7898.    * A working ANSI C++ compiler.  `gcc' 2.95.2 or later, `egcs' 1.0.2
  7899.      or later or `egcs 2.91.66', SGI C++, and SunPro C++ are some of the
  7900.      compilers that are known to work.  `libg++' is not needed when
  7901.      using `gcc'.  `gcc' 2.7.x has a bug that makes it impossible to
  7902.      compile some perfectly legal C++ files, such as `sql/sql_base.cc'.
  7903.      If you have only `gcc' 2.7.x, you must upgrade your `gcc' to be
  7904.      able to compile MySQL. `gcc' 2.8.1 is also known to have problems
  7905.      on some platforms, so it should be avoided if a new compiler
  7906.      exists for the platform.
  7907.  
  7908.      `gcc' 2.95.2 or later is recommended when compiling MySQL 3.23.x.
  7909.  
  7910.    * A good `make' program.  GNU `make' is always recommended and is
  7911.      sometimes required.  If you have problems, we recommend trying GNU
  7912.      `make' 3.75 or newer.
  7913.  
  7914. If you are using a version of `gcc' recent enough to understand the
  7915. `-fno-exceptions' option, it is _very important_ that you use this
  7916. option. Otherwise, you may compile a binary that crashes randomly. We
  7917. also recommend that you use `-felide-constructors' and `-fno-rtti' along
  7918. with `-fno-exceptions'. When in doubt, do the following:
  7919.  
  7920.      CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \
  7921.             -fno-exceptions -fno-rtti" ./configure \
  7922.             --prefix=/usr/local/mysql --enable-assembler \
  7923.             --with-mysqld-ldflags=-all-static
  7924.  
  7925. On most systems, this will give you a fast and stable binary.
  7926.  
  7927. If you run into problems, _please always use `mysqlbug'_ when posting
  7928. questions to a MySQL mailing list.  Even if the problem isn't a bug,
  7929. `mysqlbug' gathers system information that will help others solve your
  7930. problem.  By not using `mysqlbug', you lessen the likelihood of getting
  7931. a solution to your problem.  You will find `mysqlbug' in the `scripts'
  7932. directory after you unpack the distribution.  *Note Bug reports::.
  7933.  
  7934. Source Installation Overview
  7935. ----------------------------
  7936.  
  7937. The basic commands you must execute to install a MySQL source
  7938. distribution are:
  7939.  
  7940.      shell> groupadd mysql
  7941.      shell> useradd -g mysql mysql
  7942.      shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
  7943.      shell> cd mysql-VERSION
  7944.      shell> ./configure --prefix=/usr/local/mysql
  7945.      shell> make
  7946.      shell> make install
  7947.      shell> cp support-files/my-medium.cnf /etc/my.cnf
  7948.      shell> cd /usr/local/mysql
  7949.      shell> bin/mysql_install_db --user=mysql
  7950.      shell> chown -R root  .
  7951.      shell> chown -R mysql var
  7952.      shell> chgrp -R mysql .
  7953.      shell> bin/mysqld_safe --user=mysql &
  7954.  
  7955. For versions of MySQL older than 4.0, substitute `bin/safe_mysqld' for
  7956. `bin/mysqld_safe' in the final command.
  7957.  
  7958. If you start from a source RPM, do the following:
  7959.  
  7960.      shell> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm
  7961.  
  7962. This will make a binary RPM that you can install. For older versions of
  7963. RPM, you may have to replace the command `rpmbuild' with `rpm' instead.
  7964.  
  7965. *Note*: This procedure does not set up any passwords for MySQL
  7966. accounts.  After following the procedure, proceed to *Note
  7967. Post-installation::, for post-installation setup and testing.
  7968.  
  7969. A more detailed version of the preceding description for installing
  7970. MySQL from a source distribution follows:
  7971.  
  7972.   1. Add a login user and group for `mysqld' to run as:
  7973.  
  7974.           shell> groupadd mysql
  7975.           shell> useradd -g mysql mysql
  7976.  
  7977.      These commands add the `mysql' group and the `mysql' user.  The
  7978.      syntax for `useradd' and `groupadd' may differ slightly on
  7979.      different versions of Unix.  They may also be called `adduser' and
  7980.      `addgroup'.
  7981.  
  7982.      You might want to call the user and group something else instead
  7983.      of `mysql'.  If so, substitute the appropriate name in the
  7984.      following steps.
  7985.  
  7986.   2. Pick the directory under which you want to unpack the
  7987.      distribution, and change location into it.
  7988.  
  7989.   3. Obtain a distribution file from one of the sites listed in *Note
  7990.      Getting MySQL: Getting MySQL.
  7991.  
  7992.   4. Unpack the distribution into the current directory:
  7993.           shell> gunzip < /PATH/TO/MYSQL-VERSION.tar.gz | tar xvf -
  7994.  
  7995.      This command creates a directory named `mysql-VERSION'.
  7996.  
  7997.      With GNU `tar', no separate invocation of `gunzip' is necessary.
  7998.      You can use the following alternative command to uncompress and
  7999.      extract the distribution:
  8000.  
  8001.           shell> tar zxvf /PATH/TO/MYSQL-VERSION-OS.tar.gz
  8002.  
  8003.   5. Change location into the top-level directory of the unpacked
  8004.      distribution:
  8005.  
  8006.           shell> cd mysql-VERSION
  8007.  
  8008.      Note that currently you must configure and build MySQL from this
  8009.      top-level directory.  You cannot build it in a different directory.
  8010.  
  8011.   6. Configure the release and compile everything:
  8012.  
  8013.           shell> ./configure --prefix=/usr/local/mysql
  8014.           shell> make
  8015.  
  8016.      When you run `configure', you might want to specify some options.
  8017.      Run `./configure --help' for a list of options.  *Note `configure'
  8018.      options: configure options, discusses some of the more useful
  8019.      options.
  8020.  
  8021.      If `configure' fails and you are going to send mail to a MySQL
  8022.      mailing list to ask for assistance, please include any lines from
  8023.      `config.log' that you think can help solve the problem.  Also
  8024.      include the last couple of lines of output from `configure'.  Post
  8025.      the bug report using the `mysqlbug' script.  *Note Bug reports::.
  8026.  
  8027.      If the compile fails, see *Note Compilation problems:: for help.
  8028.  
  8029.   7. Install the distribution:
  8030.  
  8031.           shell> make install
  8032.  
  8033.      If you want to set up an option file, use one of those present in
  8034.      the `support-files' directory as a template. For example:
  8035.  
  8036.           shell> cp support-files/my-medium.cnf /etc/my.cnf
  8037.  
  8038.      You might need to run these commands as `root'.
  8039.  
  8040.      If you want to configure support for `InnoDB' tables, you should
  8041.      edit the `/etc/my.cnf' file, remove the `#' character before the
  8042.      option lines that start with `innodb_...', and modify the option
  8043.      values to be what you want.  See *Note Option files:: and *Note
  8044.      `InnoDB' configuration: InnoDB configuration.
  8045.  
  8046.   8. Change location into the installation directory:
  8047.  
  8048.           shell> cd /usr/local/mysql
  8049.  
  8050.   9. If you haven't installed MySQL before, you must create the MySQL
  8051.      grant tables:
  8052.  
  8053.           shell> bin/mysql_install_db --user=mysql
  8054.  
  8055.      If you run the command as `root', you should use the `--user'
  8056.      option as shown.  The value of the option should be the name of
  8057.      the login account that you created in the first step to use for
  8058.      running the server.  If you run the command while logged in as
  8059.      that user, you can omit the `--user' option.
  8060.  
  8061.      Note that for MySQL versions older than 3.22.10,
  8062.      `mysql_install_db' left the server running after creating the grant
  8063.      tables.  This is no longer true; you will need to restart the
  8064.      server after performing the remaining steps in this procedure.
  8065.  
  8066.  10. Change the ownership of program binaries to `root' and ownership
  8067.      of the data directory to the user that you will run `mysqld' as.
  8068.      Assuming that you are located in the installation directory
  8069.      (`/usr/local/mysql'), the commands look like this:
  8070.  
  8071.           shell> chown -R root  .
  8072.           shell> chown -R mysql var
  8073.           shell> chgrp -R mysql .
  8074.  
  8075.      The first command changes the owner attribute of the files to the
  8076.      `root' user. The second changes the owner attribute of the data
  8077.      directory to the `mysql' user. The third changes the group
  8078.      attribute to the `mysql' group.
  8079.  
  8080.  11. If you would like MySQL to start automatically when you boot your
  8081.      machine, you can copy `support-files/mysql.server' to the location
  8082.      where your system has its startup files.  More information can be
  8083.      found in the `support-files/mysql.server' script itself and in
  8084.      *Note Automatic start::.
  8085.  
  8086.  12. You can set up new accounts using the `bin/mysql_setpermission'
  8087.      script if you install the `DBI' and `DBD::mysql' Perl modules.
  8088.      For instructions, see *Note Perl support::.
  8089.  
  8090.  
  8091. After everything has been installed, you should initialize and test your
  8092. distribution using this command:
  8093.  
  8094.      shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &
  8095.  
  8096. For versions of MySQL older than 4.0, substitute `safe_mysqld' for
  8097. `mysqld_safe' in the command.
  8098.  
  8099. If that command fails immediately and prints `mysqld ended', you can
  8100. find some information in the `HOST_NAME.err' file in the data directory.
  8101.  
  8102. More information about `mysqld_safe' is given in *Note `mysqld_safe':
  8103. mysqld_safe.
  8104.  
  8105. *Note*: The accounts that are listed in the MySQL grant tables
  8106. initially have no passwords.  After starting the server, you should set
  8107. up passwords for them using the instructions in *Note
  8108. Post-installation::.
  8109.  
  8110. Typical `configure' Options
  8111. ---------------------------
  8112.  
  8113. The `configure' script gives you a great deal of control over how you
  8114. configure a MySQL source distribution.  Typically you do this using
  8115. options on the `configure' command line.  You can also affect
  8116. `configure' using certain environment variables.  *Note Environment
  8117. variables::.  For a list of options supported by `configure', run this
  8118. command:
  8119.  
  8120.      shell> ./configure --help
  8121.  
  8122. Some of the more commonly used `configure' options are described here:
  8123.  
  8124.    * To compile just the MySQL client libraries and client programs and
  8125.      not the server, use the `--without-server' option:
  8126.  
  8127.           shell> ./configure --without-server
  8128.  
  8129.      If you don't have a C++ compiler, `mysql' will not compile (it is
  8130.      the one client program that requires C++).  In this case, you can
  8131.      remove the code in `configure' that tests for the C++ compiler and
  8132.      then run `./configure' with the `--without-server' option. The
  8133.      compile step will still try to build `mysql', but you can ignore
  8134.      any warnings about `mysql.cc'.  (If `make' stops, try `make -k' to
  8135.      tell it to continue with the rest of the build even if errors
  8136.      occur.)
  8137.  
  8138.    * If you want to build the embedded MySQL library (`libmysqld.a')
  8139.      you should use the `--with-embedded-server' option.
  8140.  
  8141.    * If you don't want your log files and database directories located
  8142.      under `/usr/local/var', use a `configure' command something like
  8143.      one of these:
  8144.  
  8145.           shell> ./configure --prefix=/usr/local/mysql
  8146.           shell> ./configure --prefix=/usr/local \
  8147.                      --localstatedir=/usr/local/mysql/data
  8148.  
  8149.      The first command changes the installation prefix so that
  8150.      everything is installed under `/usr/local/mysql' rather than the
  8151.      default of `/usr/local'.  The second command preserves the default
  8152.      installation prefix, but overrides the default location for
  8153.      database directories (normally `/usr/local/var') and changes it to
  8154.      `/usr/local/mysql/data'.  After you have compiled MySQL, you can
  8155.      change these options with option files. *Note Option files::.
  8156.  
  8157.    * If you are using Unix and you want the MySQL socket located
  8158.      somewhere other than the default location (normally in the
  8159.      directory `/tmp' or `/var/run'), use a `configure' command like
  8160.      this:
  8161.  
  8162.           shell> ./configure \
  8163.                      --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
  8164.  
  8165.      The socket filename must be an absolute pathname.  You can also
  8166.      change the location of `mysql.sock' later by using a MySQL option
  8167.      file. *Note Problems with `mysql.sock': Problems with mysql.sock.
  8168.  
  8169.    * If you want to compile statically linked programs (for example, to
  8170.      make a binary distribution, to get more speed, or to work around
  8171.      problems with some Red Hat Linux distributions), run `configure'
  8172.      like this:
  8173.  
  8174.           shell> ./configure --with-client-ldflags=-all-static \
  8175.                      --with-mysqld-ldflags=-all-static
  8176.  
  8177.    * If you are using `gcc' and don't have `libg++' or `libstdc++'
  8178.      installed, you can tell `configure' to use `gcc' as your C++
  8179.      compiler:
  8180.  
  8181.           shell> CC=gcc CXX=gcc ./configure
  8182.  
  8183.      When you use `gcc' as your C++ compiler, it will not attempt to
  8184.      link in `libg++' or `libstdc++'.  This may be a good idea to do
  8185.      even if you have these libraries installed, because some versions
  8186.      of them have caused strange problems for MySQL users in the past.
  8187.  
  8188.      The following list indicates some compilers and environment
  8189.      variable settings that are commonly used with each one.
  8190.  
  8191.     `gcc' 2.7.2:
  8192.                CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors"
  8193.  
  8194.     `egcs' 1.0.3a:
  8195.                CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors \
  8196.                -fno-exceptions -fno-rtti"
  8197.  
  8198.     `gcc' 2.95.2:
  8199.                CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro \
  8200.                -felide-constructors -fno-exceptions -fno-rtti"
  8201.  
  8202.     `pgcc' 2.90.29 or newer:
  8203.                CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc \
  8204.                CXXFLAGS="-O3 -mpentiumpro -mstack-align-double \
  8205.                -felide-constructors -fno-exceptions -fno-rtti"
  8206.  
  8207.      In most cases, you can get a reasonably optimized MySQL binary by
  8208.      using the options from the preceding list and adding the following
  8209.      options to the `configure' line:
  8210.  
  8211.           --prefix=/usr/local/mysql --enable-assembler \
  8212.           --with-mysqld-ldflags=-all-static
  8213.  
  8214.      The full `configure' line would, in other words, be something like
  8215.      the following for all recent `gcc' versions:
  8216.  
  8217.           CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro \
  8218.           -felide-constructors -fno-exceptions -fno-rtti" ./configure \
  8219.           --prefix=/usr/local/mysql --enable-assembler \
  8220.           --with-mysqld-ldflags=-all-static
  8221.  
  8222.      The binaries we provide on the MySQL Web site at
  8223.      `http://www.mysql.com/' are all compiled with full optimization and
  8224.      should be perfect for most users.  *Note MySQL binaries::.  There
  8225.      are some configuration settings you can tweak to make an even
  8226.      faster binary, but these are only for advanced users.  *Note
  8227.      Compile and link options::.
  8228.  
  8229.      If the build fails and produces errors about your compiler or
  8230.      linker not being able to create the shared library
  8231.      `libmysqlclient.so.#' (where `#' is a version number), you can
  8232.      work around this problem by giving the `--disable-shared' option
  8233.      to `configure'.  In this case, `configure' will not build a shared
  8234.      `libmysqlclient.so.#' library.
  8235.  
  8236.    * By default, MySQL uses the `latin1' (ISO-8859-1) character set. To
  8237.      change the default set, use the `--with-charset' option:
  8238.           shell> ./configure --with-charset=CHARSET
  8239.      CHARSET may be one of `big5', `cp1251', `cp1257', `czech',
  8240.      `danish', `dec8', `dos', `euc_kr', `gb2312', `gbk', `german1',
  8241.      `hebrew', `hp8', `hungarian', `koi8_ru', `koi8_ukr', `latin1',
  8242.      `latin2', `sjis', `swe7', `tis620', `ujis', `usa7', or
  8243.      `win1251ukr'.  *Note Character sets::.
  8244.  
  8245.      As of MySQL 4.1.1, the default collation may also be specified.
  8246.      MySQL uses the `latin1_swedish_ci' collation. To change this, use
  8247.      the `--with-collation' option:
  8248.  
  8249.           shell> ./configure --with-collation=COLLATION
  8250.  
  8251.      To change both the character set and the collation, use both the
  8252.      `--with-charset' and `--with-collation' options.  The collation
  8253.      must be a legal collation for the character set.  (Use the `SHOW
  8254.      COLLATION' statement to determine which collations are available
  8255.      for each character set.)
  8256.  
  8257.      If you want to convert characters between the server and the
  8258.      client, you should take a look at the `SET CHARACTER SET'
  8259.      statement.  *Note `SET': SET OPTION.
  8260.  
  8261.      *Warning:* If you change character sets after having created any
  8262.      tables, you will have to run `myisamchk -r -q
  8263.      --set-character-set=CHARSET' on every table. Your indexes may be
  8264.      sorted incorrectly otherwise.  (This can happen if you install
  8265.      MySQL, create some tables, then reconfigure MySQL to use a
  8266.      different character set and reinstall it.)
  8267.  
  8268.      With the `configure' option `--with-extra-charsets=LIST', you can
  8269.      define which additional character sets should be compiled into the
  8270.      server.  LIST is either a list of character set names separated by
  8271.      spaces, `complex' to include all character sets that can't be
  8272.      dynamically loaded, or `all' to include all character sets into
  8273.      the binaries.
  8274.  
  8275.    * To configure MySQL with debugging code, use the `--with-debug'
  8276.      option:
  8277.           shell> ./configure --with-debug
  8278.      This causes a safe memory allocator to be included that can find
  8279.      some errors and that provides output about what is happening.
  8280.      *Note Debugging server::.
  8281.  
  8282.    * If your client programs are using threads, you also must compile a
  8283.      thread-safe version of the MySQL client library with the
  8284.      `--enable-thread-safe-client' configure option. This will create a
  8285.      `libmysqlclient_r' library with which you should link your threaded
  8286.      applications.  *Note Threaded clients::.
  8287.  
  8288.    * Options that pertain to particular systems can be found in the
  8289.      system-specific section of this manual.  *Note Operating System
  8290.      Specific Notes::.
  8291.  
  8292. Installing from the Development Source Tree
  8293. -------------------------------------------
  8294.  
  8295. *Caution*: You should read this section only if you are interested in
  8296. helping us test our new code. If you just want to get MySQL up and
  8297. running on your system, you should use a standard release distribution
  8298. (either a binary or source distribution will do).
  8299.  
  8300. To obtain our most recent development source tree, use these
  8301. instructions:
  8302.  
  8303.   1. Download BitKeeper from
  8304.      `http://www.bitmover.com/cgi-bin/download.cgi'.  You will need
  8305.      Bitkeeper 3.0 or newer to access our repository.
  8306.  
  8307.   2. Follow the instructions to install it.
  8308.  
  8309.   3. After BitKeeper has been installed, first go to the directory you
  8310.      want to work from, and then use one of the following commands to
  8311.      clone the MySQL version branch of your choice:
  8312.  
  8313.      To clone the old 3.23 branch, use this command:
  8314.  
  8315.           shell> bk clone bk://mysql.bkbits.net/mysql-3.23 mysql-3.23
  8316.  
  8317.      To clone the 4.0 stable (production) branch, use this command:
  8318.  
  8319.           shell> bk clone bk://mysql.bkbits.net/mysql-4.0 mysql-4.0
  8320.  
  8321.      To clone the 4.1 gamma branch, use this command:
  8322.  
  8323.           shell> bk clone bk://mysql.bkbits.net/mysql-4.1 mysql-4.1
  8324.  
  8325.      To clone the 5.0 development branch, use this command:
  8326.  
  8327.           shell> bk clone bk://mysql.bkbits.net/mysql-5.0 mysql-5.0
  8328.  
  8329.      In the preceding examples, the source tree will be set up in the
  8330.      `mysql-3.23/', `mysql-4.0/', `mysql-4.1/', or `mysql-5.0/'
  8331.      subdirectory of your current directory.
  8332.  
  8333.      If you are behind a firewall and can only initiate HTTP
  8334.      connections, you can also use BitKeeper via HTTP.
  8335.  
  8336.      If you are required to use a proxy server, set the environment
  8337.      variable `http_proxy' to point to your proxy:
  8338.  
  8339.           shell> export http_proxy="http://your.proxy.server:8080/"
  8340.  
  8341.      Now, simply replace the `bk://' with `http://' when doing a clone.
  8342.      Example:
  8343.  
  8344.           shell> bk clone http://mysql.bkbits.net/mysql-4.1 mysql-4.1
  8345.  
  8346.      The initial download of the source tree may take a while,
  8347.      depending on the speed of your connection. Please be patient.
  8348.  
  8349.   4. You will need GNU `make', `autoconf' 2.53 (or newer), `automake'
  8350.      1.5, `libtool' 1.5, and `m4' to run the next set of commands. Even
  8351.      though many operating systems already come with their own
  8352.      implementation of `make', chances are high that the compilation
  8353.      will fail with strange error messages. Therefore, it is highly
  8354.      recommended that you use GNU `make' (sometimes named `gmake')
  8355.      instead.
  8356.  
  8357.      Fortunately, a large number of operating systems already ship with
  8358.      the GNU toolchain preinstalled or supply installable packages of
  8359.      these. In any case, they can also be downloaded from the following
  8360.      locations:
  8361.  
  8362.         * `http://www.gnu.org/software/autoconf/'
  8363.  
  8364.         * `http://www.gnu.org/software/automake/'
  8365.  
  8366.         * `http://www.gnu.org/software/libtool/'
  8367.  
  8368.         * `http://www.gnu.org/software/m4/'
  8369.  
  8370.         * `http://www.gnu.org/software/make/'
  8371.  
  8372.      If you are trying to configure MySQL 4.1 or later, you will also
  8373.      need GNU `bison' 1.75 or later.  Older versions of `bison' may
  8374.      report this error:
  8375.  
  8376.           sql_yacc.yy:#####: fatal error: maximum table size (32767) exceeded
  8377.  
  8378.      Note: The maximum table size is not actually exceeded; the error
  8379.      is caused by bugs in older versions of `bison'.
  8380.  
  8381.      Versions of MySQL before version 4.1 may also compile with other
  8382.      `yacc' implementations (for example, BSD `yacc' 91.7.30). For later
  8383.      versions, GNU `bison' is required.
  8384.  
  8385.      The following example shows the typical commands required to
  8386.      configure a source tree. The first `cd' command changes location
  8387.      into the top-level directory of the tree; replace `mysql-4.0' with
  8388.      the appropriate directory name.
  8389.  
  8390.           shell> cd mysql-4.0
  8391.           shell> bk -r edit
  8392.           shell> aclocal; autoheader; autoconf; automake
  8393.           shell> (cd innobase; aclocal; autoheader; autoconf; automake)
  8394.           shell> (cd bdb/dist; sh s_all)
  8395.           shell> ./configure  # Add your favorite options here
  8396.           make
  8397.  
  8398.      The command lines that change directory into the `innobase' and
  8399.      `bdb/dist' directories are used to configure the `InnoDB' and
  8400.      Berkeley DB (`BDB') storage engines.  You can omit these command
  8401.      lines if you to not require `InnoDB' or `BDB' support.
  8402.  
  8403.      If you get some strange errors during this stage, verify that you
  8404.      really have `libtool' installed.
  8405.  
  8406.      A collection of our standard configuration scripts is located in
  8407.      the `BUILD/' subdirectory.  You may find it more convenient to use
  8408.      the `BUILD/compile-pentium-debug' script than the preceding set of
  8409.      shell commands. To compile on a different architecture, modify the
  8410.      script by removing flags that are Pentium-specific.
  8411.  
  8412.   5. When the build is done, run `make install'.  Be careful with this
  8413.      on a production machine; the command may overwrite your live
  8414.      release installation.  If you have another installation of MySQL,
  8415.      we recommend that you run `./configure' with different values for
  8416.      the `--prefix', `--with-tcp-port', and `--unix-socket-path' options
  8417.      than those used for your production server.
  8418.  
  8419.   6. Play hard with your new installation and try to make the new
  8420.      features crash.  Start by running `make test'.  *Note MySQL test
  8421.      suite::.
  8422.  
  8423.   7. If you have gotten to the `make' stage and the distribution does
  8424.      not compile, please report it in our bugs database at
  8425.      `http://bugs.mysql.com/'.  If you have installed the latest
  8426.      versions of the required GNU tools, and they crash trying to
  8427.      process our configuration files, please report that also.
  8428.      However, if you execute `aclocal' and get a `command not found'
  8429.      error or a similar problem, do not report it.  Instead, make sure
  8430.      that all the necessary tools are installed and that your `PATH'
  8431.      variable is set correctly so that your shell can find them.
  8432.  
  8433.   8. After the initial `bk clone' operation to obtain the source tree,
  8434.      you should run `bk pull' periodically to get updates.
  8435.  
  8436.   9. You can examine the change history for the tree with all the diffs
  8437.      by using `bk revtool'.  If you see some funny diffs or code that
  8438.      you have a question about, do not hesitate to send email to the
  8439.      MySQL `internals' mailing list.  *Note Mailing-list::.  Also, if
  8440.      you think you have a better idea on how to do something, send an
  8441.      email message to the same address with a patch.  `bk diffs' will
  8442.      produce a patch for you after you have made changes to the source.
  8443.      If you do not have the time to code your idea, just send a
  8444.      description.
  8445.  
  8446.  10. BitKeeper has a nice help utility that you can access via `bk
  8447.      helptool'.
  8448.  
  8449.  11. Please note that any commits (made via `bk ci' or `bk citool') will
  8450.      trigger the posting of a message with the changeset to our
  8451.      internals mailing list, as well as the usual openlogging.org
  8452.      submission with just the changeset comments.  Generally, you
  8453.      wouldn't need to use commit (since the public tree will not allow
  8454.      `bk push'), but rather use the `bk diffs' method described
  8455.      previously.
  8456.  
  8457.  
  8458. You can also browse changesets, comments, and source code online. For
  8459. example, to browse this information for MySQL 4.1, go to
  8460. `http://mysql.bkbits.net:8080/mysql-4.1'.
  8461.  
  8462. The manual is in a separate tree that can be cloned with:
  8463.  
  8464.      shell> bk clone bk://mysql.bkbits.net/mysqldoc mysqldoc
  8465.  
  8466. There are also public BitKeeper trees for MySQL Control Center and
  8467. MyODBC. They can be cloned respectively as follows.
  8468.  
  8469. To clone MySQL Control center, use this command:
  8470.  
  8471.      shell> bk clone http://mysql.bkbits.net/mysqlcc mysqlcc
  8472.  
  8473. To clone MyODBC, use this command:
  8474.  
  8475.      shell> bk clone http://mysql.bkbits.net/myodbc3 myodbc3
  8476.  
  8477. To clone Connector/NET, use this command:
  8478.  
  8479.      shell> bk clone http://mysql.bkbits.net/connector-net connector-net
  8480.  
  8481. Dealing with Problems Compiling MySQL
  8482. -------------------------------------
  8483.  
  8484. All MySQL programs compile cleanly for us with no warnings on Solaris
  8485. or Linux using `gcc'.  On other systems, warnings may occur due to
  8486. differences in system include files.  See *Note MIT-pthreads:: for
  8487. warnings that may occur when using MIT-pthreads.  For other problems,
  8488. check the following list.
  8489.  
  8490. The solution to many problems involves reconfiguring.  If you do need to
  8491. reconfigure, take note of the following:
  8492.  
  8493.    * If `configure' is run after it already has been run, it may use
  8494.      information that was gathered during its previous invocation.  This
  8495.      information is stored in `config.cache'.  When `configure' starts
  8496.      up, it looks for that file and reads its contents if it exists, on
  8497.      the assumption that the information is still correct.  That
  8498.      assumption is invalid when you reconfigure.
  8499.  
  8500.    * Each time you run `configure', you must run `make' again to
  8501.      recompile.  However, you may want to remove old object files from
  8502.      previous builds first because they were compiled using different
  8503.      configuration options.
  8504.  
  8505. To prevent old configuration information or object files from being
  8506. used, run these commands before re-running `configure':
  8507.  
  8508.      shell> rm config.cache
  8509.      shell> make clean
  8510.  
  8511. Alternatively, you can run `make distclean'.
  8512.  
  8513. The following list describes some of the problems when compiling MySQL
  8514. that have been found to occur most often:
  8515.  
  8516.    * If you get errors such as the ones shown here when compiling
  8517.      `sql_yacc.cc', you probably have run out of memory or swap space:
  8518.  
  8519.           Internal compiler error: program cc1plus got fatal signal 11
  8520.           Out of virtual memory
  8521.           Virtual memory exhausted
  8522.  
  8523.      The problem is that `gcc' requires a huge amount of memory to
  8524.      compile `sql_yacc.cc' with inline functions.  Try running
  8525.      `configure' with the `--with-low-memory' option:
  8526.  
  8527.           shell> ./configure --with-low-memory
  8528.  
  8529.      This option causes `-fno-inline' to be added to the compile line
  8530.      if you are using `gcc' and `-O0' if you are using something else.
  8531.      You should try the `--with-low-memory' option even if you have so
  8532.      much memory and swap space that you think you can't possibly have
  8533.      run out.  This problem has been observed to occur even on systems
  8534.      with generous hardware configurations and the `--with-low-memory'
  8535.      option usually fixes it.
  8536.  
  8537.    * By default, `configure' picks `c++' as the compiler name and GNU
  8538.      `c++' links with `-lg++'.  If you are using `gcc', that behavior
  8539.      can cause problems during configuration such as this:
  8540.  
  8541.           configure: error: installation or configuration problem:
  8542.           C++ compiler cannot create executables.
  8543.  
  8544.      You might also observe problems during compilation related to
  8545.      `g++', `libg++', or `libstdc++'.
  8546.  
  8547.      One cause of these problems is that you may not have `g++', or you
  8548.      may have `g++' but not `libg++', or `libstdc++'.  Take a look at
  8549.      the `config.log' file.  It should contain the exact reason why
  8550.      your C++ compiler didn't work.  To work around these problems, you
  8551.      can use `gcc' as your C++ compiler.  Try setting the environment
  8552.      variable `CXX' to `"gcc -O3"'.  For example:
  8553.  
  8554.           shell> CXX="gcc -O3" ./configure
  8555.  
  8556.      This works because `gcc' compiles C++ sources as well as `g++'
  8557.      does, but does not link in `libg++' or `libstdc++' by default.
  8558.  
  8559.      Another way to fix these problems is to install `g++', `libg++',
  8560.      and `libstdc++'.  We would, however, like to recommend that you
  8561.      not use `libg++' or `libstdc++' with MySQL because this will only
  8562.      increase the binary size of `mysqld' without giving you any
  8563.      benefits.  Some versions of these libraries have also caused
  8564.      strange problems for MySQL users in the past.
  8565.  
  8566.      Using `gcc' as the C++ compiler is also required if you want to
  8567.      compile MySQL with RAID functionality (see *Note CREATE TABLE::
  8568.      for more info on RAID table type) and you are using GNU `gcc'
  8569.      version 3 and above. If you get errors like those following during
  8570.      the linking stage when you configure MySQL to compile with the
  8571.      option `--with-raid', try to use `gcc' as your C++ compiler by
  8572.      defining the `CXX' environment variable:
  8573.  
  8574.           gcc -O3 -DDBUG_OFF -rdynamic -o isamchk isamchk.o sort.o  libnisam.a
  8575.           ../mysys/libmysys.a ../dbug/libdbug.a ../strings/libmystrings.a
  8576.            -lpthread -lz -lcrypt -lnsl -lm -lpthread
  8577.           ../mysys/libmysys.a(raid.o)(.text+0x79): In function
  8578.           `my_raid_create':: undefined reference to `operator new(unsigned)'
  8579.           ../mysys/libmysys.a(raid.o)(.text+0xdd): In function
  8580.           `my_raid_create':: undefined reference to `operator delete(void*)'
  8581.           ../mysys/libmysys.a(raid.o)(.text+0x129): In function
  8582.           `my_raid_open':: undefined reference to `operator new(unsigned)'
  8583.           ../mysys/libmysys.a(raid.o)(.text+0x189): In function
  8584.           `my_raid_open':: undefined reference to `operator delete(void*)'
  8585.           ../mysys/libmysys.a(raid.o)(.text+0x64b): In function
  8586.           `my_raid_close':: undefined reference to `operator delete(void*)'
  8587.           collect2: ld returned 1 exit status
  8588.  
  8589.    * If your compile fails with errors such as any of the following,
  8590.      you must upgrade your version of `make' to GNU `make':
  8591.  
  8592.           making all in mit-pthreads
  8593.           make: Fatal error in reader: Makefile, line 18:
  8594.           Badly formed macro assignment
  8595.      Or:
  8596.           make: file `Makefile' line 18: Must be a separator (:
  8597.      Or:
  8598.           pthread.h: No such file or directory
  8599.  
  8600.      Solaris and FreeBSD are known to have troublesome `make' programs.
  8601.  
  8602.      GNU `make' Version 3.75 is known to work.
  8603.  
  8604.    * If you want to define flags to be used by your C or C++ compilers,
  8605.      do so by adding the flags to the `CFLAGS' and `CXXFLAGS'
  8606.      environment variables.  You can also specify the compiler names
  8607.      this way using `CC' and `CXX'.  For example:
  8608.  
  8609.           shell> CC=gcc
  8610.           shell> CFLAGS=-O3
  8611.           shell> CXX=gcc
  8612.           shell> CXXFLAGS=-O3
  8613.           shell> export CC CFLAGS CXX CXXFLAGS
  8614.  
  8615.      See *Note MySQL binaries::, for a list of flag definitions that
  8616.      have been found to be useful on various systems.
  8617.  
  8618.    * If you get an error message like this, you need to upgrade your
  8619.      `gcc' compiler:
  8620.  
  8621.           client/libmysql.c:273: parse error before `__attribute__'
  8622.  
  8623.      `gcc' 2.8.1 is known to work, but we recommend using `gcc' 2.95.2
  8624.      or `egcs' 1.0.3a instead.
  8625.  
  8626.    * If you get errors such as those shown here when compiling `mysqld',
  8627.      `configure' didn't correctly detect the type of the last argument
  8628.      to `accept()', `getsockname()', or `getpeername()':
  8629.  
  8630.           cxx: Error: mysqld.cc, line 645: In this statement, the referenced
  8631.                type of the pointer value ''length'' is ''unsigned long'',
  8632.                which is not compatible with ''int''.
  8633.           new_sock = accept(sock, (struct sockaddr *)&cAddr, &length);
  8634.  
  8635.      To fix this, edit the `config.h' file (which is generated by
  8636.      `configure').  Look for these lines:
  8637.  
  8638.           /* Define as the base type of the last arg to accept */
  8639.           #define SOCKET_SIZE_TYPE XXX
  8640.  
  8641.      Change `XXX' to `size_t' or `int', depending on your operating
  8642.      system.  (Note that you will have to do this each time you run
  8643.      `configure' because `configure' regenerates `config.h'.)
  8644.  
  8645.    * The `sql_yacc.cc' file is generated from `sql_yacc.yy'.  Normally
  8646.      the build process doesn't need to create `sql_yacc.cc', because
  8647.      MySQL comes with an already generated copy.  However, if you do
  8648.      need to re-create it, you might encounter this error:
  8649.  
  8650.           "sql_yacc.yy", line XXX fatal: default action causes potential...
  8651.  
  8652.      This is a sign that your version of `yacc' is deficient.  You
  8653.      probably need to install `bison' (the GNU version of `yacc') and
  8654.      use that instead.
  8655.  
  8656.    * On Debian Linux 3.0, you need to install `gawk' instead of the
  8657.      default `mawk' if you want to compile MySQL 4.1 or higher with
  8658.      Berkeley DB support.
  8659.  
  8660.    * If you need to debug `mysqld' or a MySQL client, run `configure'
  8661.      with the `--with-debug' option, then recompile and link your
  8662.      clients with the new client library.  *Note Debugging client::.
  8663.  
  8664.    * If you get a compilation error on Linux (for example, SuSE Linux
  8665.      8.1 or Red Hat Linux 7.3) similar to the following one:
  8666.  
  8667.           libmysql.c:1329: warning: passing arg 5 of `gethostbyname_r' from
  8668.           incompatible pointer type
  8669.           libmysql.c:1329: too few arguments to function `gethostbyname_r'
  8670.           libmysql.c:1329: warning: assignment makes pointer from integer
  8671.           without a cast
  8672.           make[2]: *** [libmysql.lo] Error 1
  8673.  
  8674.      By default, the `configure' script attempts to determine the
  8675.      correct number of arguments by using `g++' the GNU C++ compiler.
  8676.      This test yields wrong results if `g++' is not installed. There
  8677.      are two ways to work around this problem:
  8678.  
  8679.         * Make sure that the GNU C++ `g++' is installed. On some Linux
  8680.           distributions, the required package is called `gpp'; on
  8681.           others, it is named `gcc-c++'.
  8682.  
  8683.         * Use `gcc' as your C++ compiler by setting the `CXX'
  8684.           environment variable to `gcc':
  8685.                export CXX="gcc"
  8686.  
  8687.      Please note that you need to run `configure' again afterward.
  8688.  
  8689.  
  8690. MIT-pthreads Notes
  8691. ------------------
  8692.  
  8693. This section describes some of the issues involved in using
  8694. MIT-pthreads.
  8695.  
  8696. On Linux, you should _not_ use MIT-pthreads. Use the installed
  8697. LinuxThreads implementation instead.  *Note Linux::.
  8698.  
  8699. If your system does not provide native thread support, you will need to
  8700. build MySQL using the MIT-pthreads package.  This includes older
  8701. FreeBSD systems, SunOS 4.x, Solaris 2.4 and earlier, and some others.
  8702. *Note Which OS::.
  8703.  
  8704. Beginning with MySQL 4.0.2, MIT-pthreads is no longer part of the
  8705. source distribution. If you require this package, you need to download
  8706. it separately from
  8707. `http://www.mysql.com/Downloads/Contrib/pthreads-1_60_beta6-mysql.tar.gz'
  8708.  
  8709. After downloading, extract this source archive into the top level of the
  8710. MySQL source directory. It will create a new subdirectory named
  8711. `mit-pthreads'.
  8712.  
  8713.    * On most systems, you can force MIT-pthreads to be used by running
  8714.      `configure' with the `--with-mit-threads' option:
  8715.  
  8716.           shell> ./configure --with-mit-threads
  8717.  
  8718.      Building in a non-source directory is not supported when using
  8719.      MIT-pthreads because we want to minimize our changes to this code.
  8720.  
  8721.    * The checks that determine whether to use MIT-pthreads occur only
  8722.      during the part of the configuration process that deals with the
  8723.      server code.  If you have configured the distribution using
  8724.      `--without-server' to build only the client code, clients will not
  8725.      know whether MIT-pthreads is being used and will use Unix socket
  8726.      connections by default.  Because Unix socket files do not work
  8727.      under MIT-pthreads on some platforms, this means you will need to
  8728.      use `-h' or `--host' when you run client programs.
  8729.  
  8730.    * When MySQL is compiled using MIT-pthreads, system locking is
  8731.      disabled by default for performance reasons.  You can tell the
  8732.      server to use system locking with the `--external-locking' option.
  8733.      This is needed only if you want to be able to run two MySQL
  8734.      servers against the same data files, which is not recommended.
  8735.  
  8736.    * Sometimes the pthread `bind()' command fails to bind to a socket
  8737.      without any error message (at least on Solaris).  The result is
  8738.      that all connections to the server fail.  For example:
  8739.  
  8740.           shell> mysqladmin version
  8741.           mysqladmin: connect to server at '' failed;
  8742.           error: 'Can't connect to mysql server on localhost (146)'
  8743.  
  8744.      The solution to this is to kill the `mysqld' server and restart it.
  8745.      This has only happened to us when we have forced down the server
  8746.      and done a restart immediately.
  8747.  
  8748.    * With MIT-pthreads, the `sleep()' system call isn't interruptible
  8749.      with `SIGINT' (break).  This is only noticeable when you run
  8750.      `mysqladmin --sleep'.  You must wait for the `sleep()' call to
  8751.      terminate before the interrupt is served and the process stops.
  8752.  
  8753.    * When linking, you may receive warning messages like these (at
  8754.      least on Solaris); they can be ignored:
  8755.  
  8756.           ld: warning: symbol `_iob' has differing sizes:
  8757.               (file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
  8758.           file /usr/lib/libc.so value=0x140);
  8759.               /my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
  8760.           ld: warning: symbol `__iob' has differing sizes:
  8761.               (file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
  8762.           file /usr/lib/libc.so value=0x140);
  8763.               /my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
  8764.  
  8765.    * Some other warnings also can be ignored:
  8766.  
  8767.           implicit declaration of function `int strtoll(...)'
  8768.           implicit declaration of function `int strtoul(...)'
  8769.  
  8770.    * We haven't gotten `readline' to work with MIT-pthreads.  (This
  8771.      isn't needed, but may be interesting for someone.)
  8772.  
  8773. Installing MySQL from Source on Windows
  8774. ---------------------------------------
  8775.  
  8776. These instructions describe how to build MySQL binaries from source for
  8777. versions 4.1 and above on Windows. Instructions are provided for
  8778. building binaries from a standard source distribution or from the
  8779. BitKeeper tree that contains the latest development source.
  8780.  
  8781. *Note*: The instructions in this document are strictly for users who
  8782. want to test MySQL on Windows from the latest source distribution or
  8783. from the BitKeeper tree.  For production use, MySQL AB does not advise
  8784. using a MySQL server built by yourself from source.  Normally, it is
  8785. best to use precompiled binary distributions of MySQL that are built
  8786. specifically for optimal performance on Windows by MySQL AB.
  8787. Instructions for installing a binary distributions are available at
  8788. *Note Windows installation::.
  8789.  
  8790. To build MySQL on Windows from source, you need the following compiler
  8791. and resources available on your Windows system:
  8792.  
  8793.    * VC++ 6.0 compiler (updated with 4 or 5 SP and pre-processor
  8794.      package).  The pre-processor package is necessary for the macro
  8795.      assembler.  More details can be found at
  8796.      `http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp5/faq.aspx'.
  8797.  
  8798.    * Approximately 45MB disk space.
  8799.  
  8800.    * 64MB RAM.
  8801.  
  8802.  
  8803. You'll also need a MySQL source distribution for Windows.  There are
  8804. two ways you can get a source distribution for MySQL version 4.1 and
  8805. above:
  8806.  
  8807.   1. Obtain a source distribution packaged by MySQL AB for the
  8808.      particular version of MySQL in which you are interested.
  8809.      Prepackaged source distributions are available for released
  8810.      versions of MySQL and can be obtained from
  8811.      `http://dev.mysql.com/downloads/'.
  8812.  
  8813.   2. You can package a source distribution yourself from the latest
  8814.      BitKeeper developer source tree. If you plan to do this, you must
  8815.      create the package on a Unix system and then transfer it to your
  8816.      Windows system.  (The reason for this is that some of the
  8817.      configuration and build steps require tools that work only on
  8818.      Unix.)  The BitKeeper approach thus requires:
  8819.  
  8820.         * A system running Unix, or a Unix-like system such as Linux.
  8821.  
  8822.         * BitKeeper 3.0 installed on that system. You can obtain
  8823.           BitKeeper from `http://www.bitkeeper.com/'.
  8824.  
  8825.  
  8826.  
  8827. If you are using a Windows source distribution, you can go directly to
  8828. *Note Windows VC++ Build::. To build from the BitKeeper tree, proceed to
  8829. *Note Windows BitKeeper Build::.
  8830.  
  8831. If you find something not working as expected, or you have suggestions
  8832. about ways to improve the current build process on Windows, please send
  8833. a message to the `win32' mailing list.  *Note Mailing-list::.
  8834.  
  8835. Building MySQL Using VC++
  8836. .........................
  8837.  
  8838. *Note*: VC++ workspace files for MySQL 4.1 and above are compatible with
  8839. Microsoft Visual Studio 6.0 and above (7.0/.NET) editions and tested by
  8840. MySQL AB staff before each release.
  8841.  
  8842. Follow this procedure to build MySQL:
  8843.  
  8844.   1. Create a work directory (for example, `C:\workdir').
  8845.  
  8846.   2. Unpack the source distribution in the aforementioned directory
  8847.      using `WinZip' or other Windows tool that can read `.zip' files.
  8848.  
  8849.   3. Start the VC++ 6.0 compiler.
  8850.  
  8851.   4. In the `File' menu, select `Open Workspace'.
  8852.  
  8853.   5. Open the `mysql.dsw' workspace you find in the work directory.
  8854.  
  8855.   6. From the `Build' menu, select the `Set Active Configuration' menu.
  8856.  
  8857.   7. Click over the screen selecting `mysqld - Win32 Debug' and click
  8858.      OK.
  8859.  
  8860.   8. Press `F7' to begin the build of the debug server, libraries, and
  8861.      some client applications.
  8862.  
  8863.   9. Compile the release versions that you want in the same way.
  8864.  
  8865.  10. Debug versions of the programs and libraries are placed in the
  8866.      `client_debug' and `lib_debug' directories.  Release versions of
  8867.      the programs and libraries are placed in the `client_release' and
  8868.      `lib_release' directories.  Note that if you want to build both
  8869.      debug and release versions, you can select the `Build All' option
  8870.      from the `Build' menu.
  8871.  
  8872.  11. Test the server.  The server built using the preceding instructions
  8873.      will expect that the MySQL base directory and data directory are
  8874.      `C:\mysql' and `C:\mysql\data' by default. If you want to test
  8875.      your server using the source tree root directory and its data
  8876.      directory as the base directory and data directory, you will need
  8877.      to tell the server their pathnames. You can either do this on the
  8878.      command line with the `--basedir' and `--datadir' options, or
  8879.      place appropriate options in an option file (the `my.ini' file in
  8880.      your Windows directory or `C:\my.cnf').  If you have an existing
  8881.      data directory elsewhere that you want to use, you can specify its
  8882.      pathname instead.
  8883.  
  8884.  12. Start your server from the `client_release' or `client_debug'
  8885.      directory, depending on which server you want to use. The general
  8886.      server startup instructions are at *Note Windows installation::.
  8887.      You'll need to adapt the instructions appropriately if you want to
  8888.      use a different base directory or data directory.
  8889.  
  8890.  13. When the server is running in standalone fashion or as a service
  8891.      based on your configuration, try to connect to it from the `mysql'
  8892.      interactive command-line utility that exists in your
  8893.      `client_release' or `client_debug' directory.
  8894.  
  8895.  
  8896. When you are satisfied that the programs you have built are working
  8897. correctly, stop the server. Then install MySQL as follows:
  8898.  
  8899.   1. Create the directories where you want to install MySQL.  For
  8900.      example, to install into `C:\mysql', use these commands:
  8901.  
  8902.           C:\> mkdir C:\mysql
  8903.           C:\> mkdir C:\mysql\bin
  8904.           C:\> mkdir C:\mysql\data
  8905.           C:\> mkdir C:\mysql\share
  8906.           C:\> mkdir C:\mysql\scripts
  8907.  
  8908.      If you want to compile other clients and link them to MySQL, you
  8909.      should also create several additional directories:
  8910.  
  8911.           C:\> mkdir C:\mysql\include
  8912.           C:\> mkdir C:\mysql\lib
  8913.           C:\> mkdir C:\mysql\lib\debug
  8914.           C:\> mkdir C:\mysql\lib\opt
  8915.  
  8916.      If you want to benchmark MySQL, create this directory:
  8917.  
  8918.           C:\> mkdir C:\mysql\sql-bench
  8919.  
  8920.      Benchmarking requires Perl support.
  8921.  
  8922.   2. From the `workdir' directory, copy into the `C:\mysql' directory
  8923.      the following directories:
  8924.  
  8925.           C:\> cd \workdir
  8926.           C:\workdir> copy client_release\*.exe C:\mysql\bin
  8927.           C:\workdir> copy client_debug\mysqld.exe C:\mysql\bin\mysqld-debug.exe
  8928.           C:\workdir> xcopy scripts\*.* C:\mysql\scripts /E
  8929.           C:\workdir> xcopy share\*.* C:\mysql\share /E
  8930.  
  8931.      If you want to compile other clients and link them to MySQL, you
  8932.      should also copy several libraries and header files:
  8933.  
  8934.           C:\workdir> copy lib_debug\mysqlclient.lib C:\mysql\lib\debug
  8935.           C:\workdir> copy lib_debug\libmysql.* C:\mysql\lib\debug
  8936.           C:\workdir> copy lib_debug\zlib.* C:\mysql\lib\debug
  8937.           C:\workdir> copy lib_release\mysqlclient.lib C:\mysql\lib\opt
  8938.           C:\workdir> copy lib_release\libmysql.* C:\mysql\lib\opt
  8939.           C:\workdir> copy lib_release\zlib.* C:\mysql\lib\opt
  8940.           C:\workdir> copy include\*.h C:\mysql\include
  8941.           C:\workdir> copy libmysql\libmysql.def C:\mysql\include
  8942.  
  8943.      If you want to benchmark MySQL, you should also do this:
  8944.  
  8945.           C:\workdir> xcopy sql-bench\*.* C:\mysql\bench /E
  8946.  
  8947.  
  8948. Set up and start the server in the same way as for the binary Windows
  8949. distribution.  *Note Windows installation::.
  8950.  
  8951. Creating a Windows Source Package from the Latest Development Source
  8952. ....................................................................
  8953.  
  8954. To create a Windows source package from the current BitKeeper source
  8955. tree, use the following instructions. Please note that this procedure
  8956. must be performed on a system running a Unix or Unix-like operating
  8957. system.  For example, the procedure is known to work well on Linux.
  8958.  
  8959.   1. Clone the BitKeeper source tree for MySQL (version 4.1 or above,
  8960.      as desired).  For more information on how to clone the source tree,
  8961.      see the instructions at *Note Installing source tree::.
  8962.  
  8963.   2. Configure and build the distribution so that you have a server
  8964.      binary to work with.  One way to do this is to run the following
  8965.      command in the top-level directory of your source tree:
  8966.  
  8967.           shell> ./BUILD/compile-pentium-max
  8968.  
  8969.   3. After making sure that the build process completed successfully,
  8970.      run the following utility script from top-level directory of your
  8971.      source tree:
  8972.  
  8973.           shell> ./scripts/make_win_src_distribution
  8974.  
  8975.      This script creates a Windows source package to be used on your
  8976.      Windows system.  You can supply different options to the script
  8977.      based on your needs. It accepts the following options:
  8978.  
  8979.     `--help'
  8980.           Display a help message.
  8981.  
  8982.     `--debug'
  8983.           Print information about script operations, do not create
  8984.           package.
  8985.  
  8986.     `--tmp'
  8987.           Specify the temporary location.
  8988.  
  8989.     `--suffix'
  8990.           Suffix name for the package.
  8991.  
  8992.     `--dirname'
  8993.           Directory name to copy files (intermediate).
  8994.  
  8995.     `--silent'
  8996.           Do not print verbose list of files processed.
  8997.  
  8998.     `--tar'
  8999.           Create `tar.gz' package instead of `.zip' package.
  9000.  
  9001.      By default, `make_win_src_distribution' creates a Zip-format
  9002.      archive with the name `mysql-VERSION-win-src.zip', where VERSION
  9003.      represents the version of your MySQL source tree.
  9004.  
  9005.   4. Copy or upload to your Windows machine the Windows source package
  9006.      that you have just created. To compile it, use the instructions in
  9007.      *Note Windows VC++ Build::.
  9008.  
  9009.  
  9010. Compiling MySQL Clients on Windows
  9011. ----------------------------------
  9012.  
  9013. In your source files, you should include `my_global.h' before `mysql.h':
  9014.  
  9015.      #include <my_global.h>
  9016.      #include <mysql.h>
  9017.  
  9018. `my_global.h' includes any other files needed for Windows compatibility
  9019. (such as `windows.h') if you compile your program on Windows.
  9020.  
  9021. You can either link your code with the dynamic `libmysql.lib' library,
  9022. which is just a wrapper to load in `libmysql.dll' on demand, or link
  9023. with the static `mysqlclient.lib' library.
  9024.  
  9025. The MySQL client libraries are compiled as threaded libraries, so you
  9026. should also compile your code to be multi-threaded.
  9027.  
  9028. Post-Installation Setup and Testing
  9029. ===================================
  9030.  
  9031. After installing MySQL, there are some issues you should address.  For
  9032. example, on Unix, you should initialize the data directory and create
  9033. the MySQL grant tables.  On all platforms, an important security
  9034. concern is that the initial accounts in the grant tables have no
  9035. passwords.  You should assign passwords to prevent unauthorized access
  9036. to the MySQL server.  For MySQL 4.1.3 and up, you can create time zone
  9037. tables to enable recognition of named time zones. (Currently, these
  9038. tables can be populated only on Unix. This problem will be addressed
  9039. soon for Windows.)
  9040.  
  9041. The following sections include post-installation procedures that are
  9042. specific to Windows systems and to Unix systems. Another section, *Note
  9043. Starting server::, applies to all platforms; it describes what to do if
  9044. you have trouble getting the server to start.  *Note Default
  9045. privileges:: also applies to all platforms. You should follow its
  9046. instructions to make sure that you have properly protected your MySQL
  9047. accounts by assigning passwords to them.
  9048.  
  9049. When you are ready to create additional user accounts, you can find
  9050. information on the MySQL access control system and account management in
  9051. *Note Privilege system:: and *Note User Account Management::.
  9052.  
  9053. Windows Post-Installation Procedures
  9054. ------------------------------------
  9055.  
  9056. On Windows, the data directory and the grant tables do not have to be
  9057. created. MySQL Windows distributions include the grant tables already
  9058. set up with a set of preinitialized accounts in the `mysql' database
  9059. under the data directory. You do not run the `mysql_install_db' script
  9060. that is used on Unix.  However, you should assign passwords to the
  9061. accounts.  The procedure for this is given in *Note Default
  9062. privileges::.
  9063.  
  9064. Before setting up passwords, you might want to try running some client
  9065. programs to make sure that you can connect to the server and that it is
  9066. operating properly.  Make sure the server is running (*note Windows
  9067. server first start::), then issue the following commands to verify that
  9068. you can retrieve information from the server.  The output should be
  9069. similar to what is shown here:
  9070.  
  9071.      C:\> C:\mysql\bin\mysqlshow
  9072.      +-----------+
  9073.      | Databases |
  9074.      +-----------+
  9075.      | mysql     |
  9076.      | test      |
  9077.      +-----------+
  9078.      
  9079.      C:\> C:\mysql\bin\mysqlshow mysql
  9080.      Database: mysql
  9081.      +--------------+
  9082.      |    Tables    |
  9083.      +--------------+
  9084.      | columns_priv |
  9085.      | db           |
  9086.      | func         |
  9087.      | host         |
  9088.      | tables_priv  |
  9089.      | user         |
  9090.      +--------------+
  9091.      
  9092.      C:\> C:\mysql\bin\mysql -e "SELECT Host,Db,User FROM db" mysql
  9093.      +------+-------+------+
  9094.      | host | db    | user |
  9095.      +------+-------+------+
  9096.      | %    | test% |      |
  9097.      +------+-------+------+
  9098.  
  9099. If you are running a version of Windows that supports services and you
  9100. want the MySQL server to run automatically when Windows starts, see
  9101. *Note NT start::.
  9102.  
  9103. Unix Post-Installation Procedures
  9104. ---------------------------------
  9105.  
  9106. After installing MySQL on Unix, you need to initialize the grant tables,
  9107. start the server, and make sure that the server works okay.  You may
  9108. also wish to arrange for the server to be started and stopped
  9109. automatically when your system starts and stops.  You should also
  9110. assign passwords to the accounts in the grant tables.
  9111.  
  9112. On Unix, the grant tables are set up by the `mysql_install_db' program.
  9113. For some installation methods, this program is run for you
  9114. automatically:
  9115.  
  9116.    * If you install MySQL on Linux using RPM distributions, the server
  9117.      RPM runs `mysql_install_db'.
  9118.  
  9119.    * If you install MySQL on Mac OS X using a PKG distribution, the
  9120.      installer runs `mysql_install_db'.
  9121.  
  9122. Otherwise, you'll need to run `mysql_install_db' yourself.
  9123.  
  9124. The following procedure describes how to initialize the grant tables (if
  9125. that has not already been done) and then start the server. It also
  9126. suggests some commands that you can use to test whether the server is
  9127. accessible and working properly.  For information about starting and
  9128. stopping the server automatically, see *Note Automatic start::.
  9129.  
  9130. After you complete the procedure and have the server running, you should
  9131. assign passwords to the accounts created by `mysql_install_db'.
  9132. Instructions for doing so are given in *Note Default privileges::.
  9133.  
  9134. In the examples shown here, the server runs under the user ID of the
  9135. `mysql' login account. This assumes that such an account exists.
  9136. Either create the account if it does not exist, or substitute the name
  9137. of a different existing login account that you plan to use for running
  9138. the server.
  9139.  
  9140.   1. Change location into the top-level directory of your MySQL
  9141.      installation, represented here by BASEDIR:
  9142.  
  9143.           shell> cd BASEDIR
  9144.  
  9145.      BASEDIR is likely to be something like `/usr/local/mysql' or
  9146.      `/usr/local'.  The following steps assume that you are located in
  9147.      this directory.
  9148.  
  9149.   2. If necessary, run the `mysql_install_db' program to set up the
  9150.      initial MySQL grant tables containing the privileges that
  9151.      determine how users are allowed to connect to the server. You'll
  9152.      need to do this if you used a distribution type that doesn't run
  9153.      the program for you.
  9154.  
  9155.      Typically, `mysql_install_db' needs to be run only the first time
  9156.      you install MySQL, so you can skip this step if you are upgrading
  9157.      an existing installation, However, `mysql_install_db' does not
  9158.      overwrite any existing privilege tables, so it should be safe to
  9159.      run in any circumstances.
  9160.  
  9161.      To initialize the grant tables, use one of the following commands,
  9162.      depending on whether `mysql_install_db' is located in the `bin' or
  9163.      `scripts' directory:
  9164.  
  9165.           shell> bin/mysql_install_db --user=mysql
  9166.           shell> scripts/mysql_install_db --user=mysql
  9167.  
  9168.      The `mysql_install_db' script creates the data directory, the
  9169.      `mysql' database that holds all database privileges, and the `test'
  9170.      database that you can use to test MySQL. The script also creates
  9171.      privilege table entries for `root' accounts and anonymous-user
  9172.      accounts.  The accounts have no passwords initially.  A
  9173.      description of their initial privileges is given in *Note Default
  9174.      privileges::.  Briefly, these privileges allow the MySQL `root'
  9175.      user to do anything, and allow anybody to create or use databases
  9176.      with a name of `test' or starting with `test_'.
  9177.  
  9178.      It is important to make sure that the database directories and
  9179.      files are owned by the `mysql' login account so that the server
  9180.      has read and write access to them when you run it later. To ensure
  9181.      this, the `--user' option should be used as shown if you run
  9182.      `mysql_install_db' as `root'. Otherwise, you should execute the
  9183.      script while logged in as `mysql', in which case you can omit the
  9184.      `--user' option from the command.
  9185.  
  9186.      `mysql_install_db' creates several tables in the `mysql' database:
  9187.      `user', `db', `host', `tables_priv', `columns_priv', `func', and
  9188.      possibly others depending on your version of MySQL.
  9189.  
  9190.      If you don't want to have the `test' database, you can remove it
  9191.      with `mysqladmin -u root drop test' after starting the server.
  9192.  
  9193.      If you have problems with `mysql_install_db', see *Note
  9194.      `mysql_install_db': mysql_install_db.
  9195.  
  9196.      There are some alternatives to running the `mysql_install_db'
  9197.      script as it is provided in the MySQL distribution:
  9198.  
  9199.         * If you want the initial privileges to be different from the
  9200.           standard defaults, you can modify `mysql_install_db' before
  9201.           you run it.  However, a preferable technique is to use
  9202.           `GRANT' and `REVOKE' to change the privileges after the grant
  9203.           tables have been set up.  In other words, you can run
  9204.           `mysql_install_db', and then use `mysql -u root mysql' to
  9205.           connect to the server as the MySQL `root' user so that you
  9206.           can issue the `GRANT' and `REVOKE' statements.
  9207.  
  9208.           If you want to install MySQL on a lot of machines with the
  9209.           same privileges, you can put the `GRANT' and `REVOKE'
  9210.           statements in a file and execute the file as a script using
  9211.           `mysql' after running `mysql_install_db'. For example:
  9212.  
  9213.                shell> bin/mysql_install_db --user=mysql
  9214.                shell> bin/mysql -u root < your_script_file
  9215.  
  9216.           By doing this, you can avoid having to issue the statements
  9217.           manually on each machine.
  9218.  
  9219.         * It is possible to re-create the grant tables completely after
  9220.           they have already been created.  You might want to do this if
  9221.           you're just learning how to use `GRANT' and `REVOKE' and have
  9222.           made so many modifications after running `mysql_install_db'
  9223.           that you want to wipe out the tables and start over.
  9224.  
  9225.           To re-create the grant tables, remove all the `.frm', `.MYI',
  9226.           and `.MYD' files in the directory containing the `mysql'
  9227.           database.  (This is the directory named `mysql' under the
  9228.           data directory, which is listed as the `datadir' value when
  9229.           you run `mysqld --help'.) Then run the `mysql_install_db'
  9230.           script again.
  9231.  
  9232.           *Note*: For MySQL versions older than 3.22.10, you should not
  9233.           delete the `.frm' files.  If you accidentally do this, you
  9234.           should copy them back into the `mysql' directory from your
  9235.           MySQL distribution before running `mysql_install_db'.
  9236.  
  9237.         * You can start `mysqld' manually using the
  9238.           `--skip-grant-tables' option and add the privilege
  9239.           information yourself using `mysql':
  9240.  
  9241.                shell> bin/mysqld_safe --user=mysql --skip-grant-tables &
  9242.                shell> bin/mysql mysql
  9243.  
  9244.           From `mysql', manually execute the SQL commands contained in
  9245.           `mysql_install_db'.  Make sure that you run `mysqladmin
  9246.           flush-privileges' or `mysqladmin reload' afterward to tell
  9247.           the server to reload the grant tables.
  9248.  
  9249.           Note that by not using `mysql_install_db', you not only have
  9250.           to populate the grant tables manually, you also have to
  9251.           create them first.
  9252.  
  9253.   3. Start the MySQL server:
  9254.  
  9255.           shell> bin/mysqld_safe --user=mysql &
  9256.  
  9257.      For versions of MySQL older than 4.0, substitute `bin/safe_mysqld'
  9258.      for `bin/mysqld_safe' in this command.
  9259.  
  9260.      It is important that the MySQL server be run using an unprivileged
  9261.      (non-`root') login account.  To ensure this, the `--user' option
  9262.      should be used as shown if you run `mysql_safe' as `root'.
  9263.      Otherwise, you should execute the script while logged in as
  9264.      `mysql', in which case you can omit the `--user' option from the
  9265.      command.
  9266.  
  9267.      Further instructions for running MySQL as an unprivileged user are
  9268.      given in *Note Changing MySQL user::.
  9269.  
  9270.      If you neglected to create the grant tables before proceeding to
  9271.      this step, the following message will appear in the error log file
  9272.      when you start the server:
  9273.  
  9274.           mysqld: Can't find file: 'host.frm'
  9275.  
  9276.      If you have other problems starting the server, see *Note Starting
  9277.      server::.
  9278.  
  9279.   4. Use `mysqladmin' to verify that the server is running.  The
  9280.      following commands provide simple tests to check whether the
  9281.      server is up and responding to connections:
  9282.  
  9283.           shell> bin/mysqladmin version
  9284.           shell> bin/mysqladmin variables
  9285.  
  9286.      The output from `mysqladmin version' varies slightly depending on
  9287.      your platform and version of MySQL, but should be similar to that
  9288.      shown here:
  9289.  
  9290.           shell> bin/mysqladmin version
  9291.           mysqladmin  Ver 8.40 Distrib 4.0.18, for linux on i586
  9292.           Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  9293.           This software comes with ABSOLUTELY NO WARRANTY. This is free software,
  9294.           and you are welcome to modify and redistribute it under the GPL license
  9295.           
  9296.           Server version          4.0.18-log
  9297.           Protocol version        10
  9298.           Connection              Localhost via Unix socket
  9299.           TCP port                3306
  9300.           UNIX socket             /tmp/mysql.sock
  9301.           Uptime:                 16 sec
  9302.           
  9303.           Threads: 1  Questions: 9  Slow queries: 0
  9304.           Opens: 7  Flush tables: 2  Open tables: 0
  9305.           Queries per second avg: 0.000
  9306.           Memory in use: 132K  Max memory used: 16773K
  9307.  
  9308.      To see what else you can do with `mysqladmin', invoke it with the
  9309.      `--help' option.
  9310.  
  9311.   5. Verify that you can shut down the server:
  9312.  
  9313.           shell> bin/mysqladmin -u root shutdown
  9314.  
  9315.   6. Verify that you can restart the server.  Do this by using
  9316.      `mysqld_safe' or by invoking `mysqld' directly.  For example:
  9317.  
  9318.           shell> bin/mysqld_safe --user=mysql --log &
  9319.  
  9320.      If `mysqld_safe' fails, see *Note Starting server::.
  9321.  
  9322.   7. Run some simple tests to verify that you can retrieve information
  9323.      from the server.  The output should be similar to what is shown
  9324.      here:
  9325.  
  9326.           shell> bin/mysqlshow
  9327.           +-----------+
  9328.           | Databases |
  9329.           +-----------+
  9330.           | mysql     |
  9331.           | test      |
  9332.           +-----------+
  9333.           
  9334.           shell> bin/mysqlshow mysql
  9335.           Database: mysql
  9336.           +--------------+
  9337.           |    Tables    |
  9338.           +--------------+
  9339.           | columns_priv |
  9340.           | db           |
  9341.           | func         |
  9342.           | host         |
  9343.           | tables_priv  |
  9344.           | user         |
  9345.           +--------------+
  9346.           
  9347.           shell> bin/mysql -e "SELECT Host,Db,User FROM db" mysql
  9348.           +------+--------+------+
  9349.           | host | db     | user |
  9350.           +------+--------+------+
  9351.           | %    | test   |      |
  9352.           | %    | test_% |      |
  9353.           +------+--------+------+
  9354.  
  9355.   8. There is a benchmark suite in the `sql-bench' directory (under the
  9356.      MySQL installation directory) that you can use to compare how
  9357.      MySQL performs on different platforms. The benchmark suite is
  9358.      written in Perl. It uses the Perl DBI module to provide a
  9359.      database-independent interface to the various databases, and some
  9360.      other additional Perl modules are required to run the benchmark
  9361.      suite. You must have the following modules installed:
  9362.  
  9363.           DBI
  9364.           DBD::mysql
  9365.           Data::Dumper
  9366.           Data::ShowTable
  9367.  
  9368.      These modules can be obtained from CPAN (`http://www.cpan.org/').
  9369.      *Note Perl installation::.
  9370.  
  9371.      The `sql-bench/Results' directory contains the results from many
  9372.      runs against different databases and platforms.  To run all tests,
  9373.      execute these commands:
  9374.  
  9375.           shell> cd sql-bench
  9376.           shell> perl run-all-tests
  9377.  
  9378.      If you don't have the `sql-bench' directory, you probably
  9379.      installed MySQL using RPM files other than the source RPM.  (The
  9380.      source RPM includes the `sql-bench' benchmark directory.)  In this
  9381.      case, you must first install the benchmark suite before you can
  9382.      use it.  Beginning with MySQL 3.22, there are separate benchmark
  9383.      RPM files named `mysql-bench-VERSION-i386.rpm' that contain
  9384.      benchmark code and data.
  9385.  
  9386.      If you have a source distribution, there are also tests in its
  9387.      `tests' subdirectory that you can run. For example, to run
  9388.      `auto_increment.tst', execute this command from the top-level
  9389.      directory of your source distribution:
  9390.  
  9391.           shell> mysql -vvf test < ./tests/auto_increment.tst
  9392.  
  9393.      The expected result of the test can be found in the
  9394.      `./tests/auto_increment.res' file.
  9395.  
  9396.   9. At this point, you should have the server running. However, none
  9397.      of the initial MySQL accounts have a password, so you should
  9398.      assign passwords using the instructions in *Note Default
  9399.      privileges::.
  9400.  
  9401. As of MySQL 4.1.3, the installation procedure creates time zone tables
  9402. in the `mysql' database. However, you must populate the tables manually.
  9403. Instructions to do this are given in *Note Time zone support::.
  9404.  
  9405. Problems Running `mysql_install_db'
  9406. ...................................
  9407.  
  9408. The purpose of the `mysql_install_db' script is to generate new MySQL
  9409. privilege tables.  It will not overwrite existing MySQL privilege
  9410. tables, and it will not affect any other data.
  9411.  
  9412. If you want to re-create your privilege tables, first stop the `mysqld'
  9413. server if it's running. Then rename the `mysql' directory under the
  9414. data directory to save it, and then run `mysql_install_db'.  For
  9415. example:
  9416.  
  9417.      shell> mv mysql-data-directory/mysql mysql-data-directory/mysql-old
  9418.      shell> mysql_install_db --user=mysql
  9419.  
  9420. This section lists problems you might encounter when you run
  9421. `mysql_install_db':
  9422.  
  9423. *`mysql_install_db' doesn't install the grant tables*
  9424.      You may find that `mysql_install_db' fails to install the grant
  9425.      tables and terminates after displaying the following messages:
  9426.  
  9427.           Starting mysqld daemon with databases from XXXXXX
  9428.           mysqld ended
  9429.  
  9430.      In this case, you should examine the error log file very
  9431.      carefully.  The log should be located in the directory `XXXXXX'
  9432.      named by the error message, and should indicate why `mysqld'
  9433.      didn't start.  If you don't understand what happened, include the
  9434.      log when you post a bug report.  *Note Bug reports::.
  9435.  
  9436. *There is already a `mysqld' process running*
  9437.      This indicates that the server is already running, in which case
  9438.      the grant tables probably have already been created. If so, you
  9439.      don't have to run `mysql_install_db' at all because it need be run
  9440.      only once (when you install MySQL the first time).
  9441.  
  9442. *Installing a second `mysqld' server doesn't work when one server is running*
  9443.      This can happen when you already have an existing MySQL
  9444.      installation, but want to put a new installation in a different
  9445.      location.  For example, you might have a production installation
  9446.      already, but you want to create a second installation for testing
  9447.      purposes.  Generally the problem that occurs when you try to run a
  9448.      second server is that it tries to use a network interface that is
  9449.      already in use by the first server.  In this case, you will see
  9450.      one of the following error messages:
  9451.  
  9452.           Can't start server: Bind on TCP/IP port:
  9453.           Address already in use
  9454.           Can't start server: Bind on unix socket...
  9455.  
  9456.      For instructions on setting up multiple servers, see *Note
  9457.      Multiple servers::.
  9458.  
  9459. *You don't have write access to `/tmp'*
  9460.      If you don't have write access to create temporary files or a Unix
  9461.      socket file in the default location (the `/tmp' directory), an
  9462.      error will occur when you run `mysql_install_db' or the `mysqld'
  9463.      server.
  9464.  
  9465.      You can specify different temporary directory and Unix socket file
  9466.      locations by executing these commands prior to starting
  9467.      `mysql_install_db' or `mysqld':
  9468.  
  9469.           shell> TMPDIR=/some_tmp_dir/
  9470.           shell> MYSQL_UNIX_PORT=/some_tmp_dir/mysql.sock
  9471.           shell> export TMPDIR MYSQL_UNIX_PORT
  9472.  
  9473.      `some_tmp_dir' should be the full pathname to some directory for
  9474.      which you have write permission.
  9475.  
  9476.      After this, you should be able to run `mysql_install_db' and start
  9477.      the server with these commands:
  9478.  
  9479.           shell> bin/mysql_install_db --user=mysql
  9480.           shell> bin/mysqld_safe --user=mysql &
  9481.  
  9482.      If `mysql_install_db' is located in the `scripts' directory,
  9483.      modify the first command to use `scripts/mysql_install_db'.
  9484.  
  9485.      See *Note Problems with `mysql.sock': Problems with mysql.sock.
  9486.      *Note Environment variables::.
  9487.  
  9488. Starting and Stopping MySQL Automatically
  9489. .........................................
  9490.  
  9491. Generally, you start the `mysqld' server in one of these ways:
  9492.  
  9493.    * By invoking `mysqld' directly. This works on any platform.
  9494.  
  9495.    * By running the MySQL server as a Windows service.  This can be
  9496.      done on versions of Windows that support services (such as NT,
  9497.      2000, and XP). The service can be set to start the server
  9498.      automatically when Windows starts, or as a manual service that you
  9499.      start on request.  For instructions, see *Note NT start::.
  9500.  
  9501.    * By invoking `mysqld_safe', which tries to determine the proper
  9502.      options for `mysqld' and then runs it with those options.  This
  9503.      script is used on systems based on BSD Unix.  *Note `mysqld_safe':
  9504.      mysqld_safe.
  9505.  
  9506.    * By invoking `mysql.server'.  This script is used primarily at
  9507.      system startup and shutdown on systems that use System V-style run
  9508.      directories, where it usually is installed under the name `mysql'.
  9509.      The `mysql.server' script starts the server by invoking
  9510.      `mysqld_safe'.  *Note `mysql.server': mysql.server.
  9511.  
  9512.    * On Mac OS X, you can install a separate MySQL Startup Item package
  9513.      to enable the automatic startup of MySQL on system startup.  The
  9514.      Startup Item starts the server by invoking `mysql.server'.  See
  9515.      *Note Mac OS X installation:: for details.
  9516.  
  9517.  
  9518. The `mysql.server' and `mysqld_safe' scripts and the Mac OS X Startup
  9519. Item can be used to start the server manually, or automatically at
  9520. system startup time. `mysql.server' and the Startup Item also can be
  9521. used to stop the server.
  9522.  
  9523. To start or stop the server manually using the `mysql.server' script,
  9524. invoke it with `start' or `stop' arguments:
  9525.  
  9526.      shell> mysql.server start
  9527.      shell> mysql.server stop
  9528.  
  9529. Before `mysql.server' starts the server, it changes location to the
  9530. MySQL installation directory, and then invokes `mysqld_safe'.  If you
  9531. want the server to run as some specific user, add an appropriate `user'
  9532. option to the `[mysqld]' group of the `/etc/my.cnf' option file, as
  9533. shown later in this section.  (It is possible that you'll need to edit
  9534. `mysql.server' if you've installed a binary distribution of MySQL in a
  9535. non-standard location.  Modify it to `cd' into the proper directory
  9536. before it runs `mysqld_safe'.  If you do this, your modified version of
  9537. `mysql.server' may be overwritten if you upgrade MySQL in the future,
  9538. so you should make a copy of your edited version that you can
  9539. reinstall.)
  9540.  
  9541. `mysql.server stop' brings down the server by sending a signal to it.
  9542. You can also stop the server manually by executing `mysqladmin
  9543. shutdown'.
  9544.  
  9545. To start and stop MySQL automatically on your server, you need to add
  9546. start and stop commands to the appropriate places in your `/etc/rc*'
  9547. files.
  9548.  
  9549. If you use the Linux server RPM package (`MySQL-server-VERSION.rpm'),
  9550. the `mysql.server' script will already have been installed in the
  9551. `/etc/init.d' directory with the name `mysql'. You need not install it
  9552. manually. See *Note Linux-RPM:: for more information on the Linux RPM
  9553. packages.
  9554.  
  9555. Some vendors provide RPM packages that install a startup script under a
  9556. different name such as `mysqld'.
  9557.  
  9558. If you install MySQL from a source distribution or using a binary
  9559. distribution format that does not install `mysql.server' automatically,
  9560. you can install it manually. The script can be found in the
  9561. `support-files' directory under the MySQL installation directory or in
  9562. a MySQL source tree.
  9563.  
  9564. To install `mysql.server' manually, copy it to the `/etc/init.d'
  9565. directory with the name `mysql', and then make it executable.  Do this
  9566. by changing location into the appropriate directory where
  9567. `mysql.server' is located and executing these commands:
  9568.  
  9569.      shell> cp mysql.server /etc/init.d/mysql
  9570.      shell> chmod +x /etc/init.d/mysql
  9571.  
  9572. Older Red Hat systems use the `/etc/rc.d/init.d' directory rather than
  9573. `/etc/init.d'. Adjust the preceding commands accordingly. Alternatively,
  9574. first create `/etc/init.d' as a symbolic link that points to
  9575. `/etc/rc.d/init.d':
  9576.  
  9577.      shell> cd /etc
  9578.      shell> ln -s rc.d/init.d .
  9579.  
  9580. After installing the script, the commands needed to activate it to run
  9581. at system startup depend on your operating system.  On Linux, you can
  9582. use `chkconfig':
  9583.  
  9584.      shell> chkconfig --add mysql
  9585.  
  9586. On some Linux systems, the following command also seems to be necessary
  9587. to fully enable the `mysql' script:
  9588.  
  9589.      shell> chkconfig --level 345 mysql on
  9590.  
  9591. On FreeBSD, startup scripts generally should go in
  9592. `/usr/local/etc/rc.d/'. The `rc(8)' manual page states that scripts in
  9593. this directory are executed only if their basename matches the `*.sh'
  9594. shell filename pattern.  Any other files or directories present within
  9595. the directory are silently ignored. In other words, on FreeBSD, you
  9596. should install the `mysql.server' script as
  9597. `/usr/local/etc/rc.d/mysql.server.sh' to enable automatic startup.
  9598.  
  9599. As an alternative to the preceding setup, some operating systems also
  9600. use `/etc/rc.local' or `/etc/init.d/boot.local' to start additional
  9601. services on startup. To start up MySQL using this method, you could
  9602. append a command like the one following to the appropriate startup file:
  9603.  
  9604.      /bin/sh -c 'cd /usr/local/mysql; ./bin/mysqld_safe --user=mysql &'
  9605.  
  9606. For other systems, consult your operating system documentation to see
  9607. how to install startup scripts.
  9608.  
  9609. You can add options for `mysql.server' in a global `/etc/my.cnf' file.
  9610. A typical `/etc/my.cnf' file might look like this:
  9611.  
  9612.      [mysqld]
  9613.      datadir=/usr/local/mysql/var
  9614.      socket=/var/tmp/mysql.sock
  9615.      port=3306
  9616.      user=mysql
  9617.      
  9618.      [mysql.server]
  9619.      basedir=/usr/local/mysql
  9620.  
  9621. The `mysql.server' script understands the following options: `basedir',
  9622. `datadir', and `pid-file'.  If specified, they _must_ be placed in an
  9623. option file, not on the command line.  `mysql.server' understands only
  9624. `start' and `stop' as command-line arguments.
  9625.  
  9626. The following table shows which option groups the server and each
  9627. startup script read from option files:
  9628.  
  9629. *Script*       *Option Groups*
  9630. `mysqld'       `[mysqld]', `[server]', `[mysqld-major-version]'
  9631. `mysql.server' `[mysqld]', `[mysql.server]'
  9632. `mysqld_safe'  `[mysqld]', `[server]', `[mysqld_safe]'
  9633.  
  9634. `[mysqld-major-version]' means that groups with names like
  9635. `[mysqld-4.0]', `[mysqld-4.1]', and `[mysqld-5.0]' will be read by
  9636. servers having versions 4.0.x, 4.1.x, 5.0.x, and so forth.  This
  9637. feature was added in MySQL 4.0.14. It can be used to specify options
  9638. that will be read only by servers within a given release series.
  9639.  
  9640. For backward compatibility, `mysql.server' also reads the
  9641. `[mysql_server]' group and `mysqld_safe' also reads the `[safe_mysqld]'
  9642. group. However, you should update your option files to use the
  9643. `[mysql.server]' and `[mysqld_safe]' groups instead when you begin
  9644. using MySQL 4.0 or later.
  9645.  
  9646. *Note Option files::.
  9647.  
  9648. Starting and Troubleshooting the MySQL Server
  9649. .............................................
  9650.  
  9651. If you have problems starting the server, here are some things you can
  9652. try:
  9653.  
  9654.    * Specify any special options needed by the storage engines you are
  9655.      using.
  9656.  
  9657.    * Make sure that the server knows where to find the data directory.
  9658.  
  9659.    * Make sure the server can use the data directory.  The ownership and
  9660.      permissions of the data directory and its contents must be set
  9661.      such that the server can access and modify them.
  9662.  
  9663.    * Check the error log to see why the server doesn't start.
  9664.  
  9665.    * Verify that the network interfaces the server wants to use are
  9666.      available.
  9667.  
  9668.  
  9669. Some storage engines have options that control their behavior.  You can
  9670. create a `my.cnf' file and set startup options for the engines you plan
  9671. to use.  If you are going to use storage engines that support
  9672. transactional tables (`InnoDB', `BDB'), be sure that you have them
  9673. configured the way you want before starting the server:
  9674.  
  9675.    * If you are using `InnoDB' tables, refer to the `InnoDB'-specific
  9676.      startup options.  In MySQL 3.23, you must configure `InnoDB'
  9677.      explicitly or the server will fail to start.  From MySQL 4.0 on,
  9678.      `InnoDB' uses default values for its configuration options if you
  9679.      specify none.  *Note `InnoDB' configuration: InnoDB configuration.
  9680.  
  9681.    * If you are using `BDB' (Berkeley DB) tables, you should familiarize
  9682.      yourself with the different `BDB'-specific startup options.  *Note
  9683.      BDB start::.
  9684.  
  9685.  
  9686. When the `mysqld' server starts, it changes location to the data
  9687. directory.  This is where it expects to find databases and where it
  9688. expects to write log files. On Unix, the server also writes the pid
  9689. (process ID) file in the data directory.
  9690.  
  9691. The data directory location is hardwired in when the server is compiled.
  9692. This is where the server looks for the data directory by default. If
  9693. the data directory is located somewhere else on your system, the server
  9694. will not work properly.  You can find out what the default path
  9695. settings are by invoking `mysqld' with the `--verbose' and `--help'
  9696. options.  (Prior to MySQL 4.1, omit the `--verbose' option.)
  9697.  
  9698. If the defaults don't match the MySQL installation layout on your
  9699. system, you can override them by specifying options on the command line
  9700. to `mysqld' or `mysqld_safe'. You can also list the options in an
  9701. option file.
  9702.  
  9703. To specify the location of the data directory explicitly, use the
  9704. `--datadir' option. However, normally you can tell `mysqld' the
  9705. location of the base directory under which MySQL is installed and it
  9706. will look for the data directory there.  You can do this with the
  9707. `--basedir' option.
  9708.  
  9709. To check the effect of specifying path options, invoke `mysqld' with
  9710. those options followed by the `--verbose' and `--help' options.  For
  9711. example, if you change location into the directory where `mysqld' is
  9712. installed, and then run the following command, it will show the effect
  9713. of starting the server with a base directory of `/usr/local':
  9714.  
  9715.      shell> ./mysqld --basedir=/usr/local --verbose --help
  9716.  
  9717. You can specify other options such as `--datadir' as well, but note
  9718. that `--verbose' and `--help' must be the last options.  (Prior to
  9719. MySQL 4.1, omit the `--verbose' option.)
  9720.  
  9721. Once you determine the path settings you want, start the server without
  9722. `--verbose' and `--help'.
  9723.  
  9724. If `mysqld' is currently running, you can find out what path settings
  9725. it is using by executing this command:
  9726.  
  9727.      shell> mysqladmin variables
  9728.  
  9729. Or:
  9730.  
  9731.      shell> mysqladmin -h HOST_NAME variables
  9732.  
  9733. HOST_NAME is the name of the MySQL server host.
  9734.  
  9735. If you get `Errcode 13' (which means `Permission denied') when starting
  9736. `mysqld', this means that the access privileges of the data directory
  9737. or its contents do not allow the server access.  In this case, you
  9738. change the permissions for the involved files and directories so that
  9739. the server has the right to use them.  You can also start the server as
  9740. `root', but this can raise security issues and should be avoided.
  9741.  
  9742. On Unix, change location into the data directory and check the
  9743. ownership of the data directory and its contents to make sure the
  9744. server has access. For example, if the data directory is
  9745. `/usr/local/mysql/var', use this command:
  9746.  
  9747.      shell> ls -la /usr/local/mysql/var
  9748.  
  9749. If the data directory or its files or subdirectories are not owned by
  9750. the account that you use for running the server, change their ownership
  9751. to that account:
  9752.  
  9753.      shell> chown -R mysql /usr/local/mysql/var
  9754.      shell> chgrp -R mysql /usr/local/mysql/var
  9755.  
  9756. If the server fails to start up correctly, check the error log file to
  9757. see if you can find out why.  Log files are located in the data
  9758. directory (typically `C:\mysql\data' on Windows, `/usr/local/mysql/data'
  9759. for a Unix binary distribution, and `/usr/local/var' for a Unix source
  9760. distribution).  Look in the data directory for files with names of the
  9761. form `HOST_NAME.err' and `HOST_NAME.log', where HOST_NAME is the name
  9762. of your server host. (Older servers on Windows use `mysql.err' as the
  9763. error log name.)  Then check the last few lines of these files.  On
  9764. Unix, you can use `tail' to display the last few lines:
  9765.  
  9766.      shell> tail HOST_NAME.err
  9767.      shell> tail HOST_NAME.log
  9768.  
  9769. The error log contains information that indicates why the server
  9770. couldn't start.  For example, you might see something like this in the
  9771. log:
  9772.  
  9773.      000729 14:50:10  bdb:  Recovery function for LSN 1 27595 failed
  9774.      000729 14:50:10  bdb:  warning: ./test/t1.db: No such file or directory
  9775.      000729 14:50:10  Can't init databases
  9776.  
  9777. This means that you didn't start `mysqld' with the `--bdb-no-recover'
  9778. option and Berkeley DB found something wrong with its own log files
  9779. when it tried to recover your databases.  To be able to continue, you
  9780. should move away the old Berkeley DB log files from the database
  9781. directory to some other place, where you can later examine them.  The
  9782. `BDB' log files are named in sequence beginning with `log.0000000001',
  9783. where the number increases over time.
  9784.  
  9785. If you are running `mysqld' with `BDB' table support and `mysqld' dumps
  9786. core at startup, this could be due to problems with the `BDB' recovery
  9787. log.  In this case, you can try starting `mysqld' with
  9788. `--bdb-no-recover'.  If that helps, then you should remove all `BDB'
  9789. log files from the data directory and try starting `mysqld' again
  9790. without the `--bdb-no-recover' option.
  9791.  
  9792. If either of the following errors occur, it means that some other
  9793. program (perhaps another `mysqld' server) is already using the TCP/IP
  9794. port or Unix socket file that `mysqld' is trying to use:
  9795.  
  9796.      Can't start server: Bind on TCP/IP port: Address already in use
  9797.      Can't start server: Bind on unix socket...
  9798.  
  9799. Use `ps' to determine whether you have another `mysqld' server running.
  9800. If so, shut down the server before starting `mysqld' again.  (If
  9801. another server is running, and you really want to run multiple servers,
  9802. you can find information about how to do so in *Note Multiple
  9803. servers::.)
  9804.  
  9805. If no other server is running, try to execute the command `telnet
  9806. your-host-name tcp-ip-port-number'.  (The default MySQL port number is
  9807. 3306.) Then press Enter a couple of times.  If you don't get an error
  9808. message like `telnet: Unable to connect to remote host: Connection
  9809. refused', some other program is using the TCP/IP port that `mysqld' is
  9810. trying to use.  You'll need to track down what program this is and
  9811. disable it, or else tell `mysqld' to listen to a different port with the
  9812. `--port' option.  In this case, you'll also need to specify the port
  9813. number for client programs when connecting to the server via TCP/IP.
  9814.  
  9815. Another reason the port might be inaccessible is that you have a
  9816. firewall running that blocks connections to it. If so, modify the
  9817. firewall settings to allow access to the port.
  9818.  
  9819. If the server starts but you can't connect to it, you should make sure
  9820. that you have an entry in `/etc/hosts' that looks like this:
  9821.  
  9822.      127.0.0.1       localhost
  9823.  
  9824. This problem occurs only on systems that don't have a working thread
  9825. library and for which MySQL must be configured to use MIT-pthreads.
  9826.  
  9827. If you can't get `mysqld' to start, you can try to make a trace file to
  9828. find the problem by using the `--debug' option.  *Note Making trace
  9829. files::.
  9830.  
  9831. Securing the Initial MySQL Accounts
  9832. -----------------------------------
  9833.  
  9834. Part of the MySQL installation process is to set up the `mysql' database
  9835. containing the grant tables:
  9836.  
  9837.    * Windows distributions contain preinitialized grant tables that are
  9838.      installed automatically.
  9839.  
  9840.    * On Unix, the grant tables are populated by the `mysql_install_db'
  9841.      program. Some installation methods run this program for you.
  9842.      Others require that you execute it manually. For details, see
  9843.      *Note Unix post-installation::.
  9844.  
  9845. The grant tables define the initial MySQL user accounts and their access
  9846. privileges.  These accounts are set up as follows:
  9847.  
  9848.    * Two accounts are created with a username of `root'.  These are
  9849.      superuser accounts that can do anything.  The initial `root'
  9850.      account passwords are empty, so anyone can connect to the MySQL
  9851.      server as `root' _without a password_ and be granted all
  9852.      privileges.
  9853.  
  9854.         * On Windows, one `root' account is for connecting from the
  9855.           local host and the other allows connections from any host.
  9856.  
  9857.         * On Unix, both `root' accounts are for connections from the
  9858.           local host.  Connections must be made from the local host by
  9859.           specifying a hostname of `localhost' for one account, or the
  9860.           actual hostname or IP number for the other.
  9861.  
  9862.  
  9863.    * Two anonymous-user accounts are created, each with an empty
  9864.      username.  The anonymous accounts have no passwords, so anyone can
  9865.      use them to connect to the MySQL server.
  9866.  
  9867.         * On Windows, one anonymous account is for connections from the
  9868.           local host.  It has all privileges, just like the `root'
  9869.           accounts.  The other is for connections from any host and has
  9870.           all privileges for the `test' database or other databases
  9871.           with names that start with `test'.
  9872.  
  9873.         * On Unix, both anonymous accounts are for connections from the
  9874.           local host.  Connections must be made from the local host by
  9875.           specifying a hostname of `localhost' for one account, or the
  9876.           actual hostname or IP number for the other.  These accounts
  9877.           have all privileges for the `test' database or other
  9878.           databases with names that start with `test_'.
  9879.  
  9880.  
  9881.  
  9882. As noted, none of the initial accounts have passwords.  This means that
  9883. your MySQL installation is unprotected until you do something about it:
  9884.  
  9885.    * If you want to prevent clients from connecting as anonymous users
  9886.      without a password, you should either assign passwords to the
  9887.      anonymous accounts or else remove them.
  9888.  
  9889.    * You should assign passwords to the MySQL `root' accounts.
  9890.  
  9891.  
  9892. The following instructions describe how to set up passwords for the
  9893. initial MySQL accounts, first for the anonymous accounts and then for
  9894. the `root' accounts.  Replace "NEWPWD" in the examples with the actual
  9895. password that you want to use.  The instructions also cover how to
  9896. remove the anonymous accounts, should you prefer not to allow anonymous
  9897. access at all.
  9898.  
  9899. You might want to defer setting the passwords until later, so that you
  9900. don't need to specify them while you perform additional setup or
  9901. testing.  However, be sure to set them before using your installation
  9902. for any real production work.
  9903.  
  9904. To assign passwords to the anonymous accounts, you can use either `SET
  9905. PASSWORD' or `UPDATE'.  In both cases, be sure to encrypt the password
  9906. using the `PASSWORD()' function.
  9907.  
  9908. To use `SET PASSWORD' on Windows, do this:
  9909.  
  9910.      shell> mysql -u root
  9911.      mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('NEWPWD');
  9912.      mysql> SET PASSWORD FOR ''@'%' = PASSWORD('NEWPWD');
  9913.  
  9914. To use `SET PASSWORD' on Unix, do this:
  9915.  
  9916.      shell> mysql -u root
  9917.      mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('NEWPWD');
  9918.      mysql> SET PASSWORD FOR ''@'HOST_NAME' = PASSWORD('NEWPWD');
  9919.  
  9920. In the second `SET PASSWORD' statement, replace HOST_NAME with the name
  9921. of the server host.  This is the name that is specified in the `Host'
  9922. column of the non-`localhost' record for `root' in the `user' table.
  9923. If you don't know what hostname this is, issue the following statement
  9924. before using `SET PASSWORD':
  9925.  
  9926.      mysql> SELECT Host, User FROM mysql.user;
  9927.  
  9928. Look for the record that has `root' in the `User' column and something
  9929. other than `localhost' in the `Host' column. Then use that `Host' value
  9930. in the second `SET PASSWORD' statement.
  9931.  
  9932. The other way to assign passwords to the anonymous accounts is by using
  9933. `UPDATE' to modify the `user' table directly.  Connect to the server as
  9934. `root' and issue an `UPDATE' statement that assigns a value to the
  9935. `Password' column of the appropriate `user' table records.  The
  9936. procedure is the same for Windows and Unix.  The following `UPDATE'
  9937. statement assigns a password to both anonymous accounts at once:
  9938.  
  9939.      shell> mysql -u root
  9940.      mysql> UPDATE mysql.user SET Password = PASSWORD('NEWPWD')
  9941.          ->     WHERE User = '';
  9942.      mysql> FLUSH PRIVILEGES;
  9943.  
  9944. After you update the passwords in the `user' table directly using
  9945. `UPDATE', you must tell the server to re-read the grant tables with
  9946. `FLUSH PRIVILEGES'. Otherwise, the change will go unnoticed until you
  9947. restart the server.
  9948.  
  9949. If you prefer to remove the anonymous accounts instead, do so as
  9950. follows:
  9951.  
  9952.      shell> mysql -u root
  9953.      mysql> DELETE FROM mysql.user WHERE User = '';
  9954.      mysql> FLUSH PRIVILEGES;
  9955.  
  9956. The `DELETE' statement applies both to Windows and to Unix.  On
  9957. Windows, if you want to remove only the anonymous account that has the
  9958. same privileges as `root', do this instead:
  9959.  
  9960.      shell> mysql -u root
  9961.      mysql> DELETE FROM mysql.user WHERE Host='localhost' AND User='';
  9962.      mysql> FLUSH PRIVILEGES;
  9963.  
  9964. This account allows anonymous access but has full privileges, so
  9965. removing it improves security.
  9966.  
  9967. You can assign passwords to the `root' accounts in several ways. The
  9968. following discussion demonstrates three methods:
  9969.  
  9970.    * Use the `SET PASSWORD' statement
  9971.  
  9972.    * Use the `mysqladmin' command-line client program
  9973.  
  9974.    * Use the `UPDATE' statement
  9975.  
  9976. To assign passwords using `SET PASSWORD', connect to the server as
  9977. `root' and issue two `SET PASSWORD' statements.  Be sure to encrypt the
  9978. password using the `PASSWORD()' function.
  9979.  
  9980. For Windows, do this:
  9981.  
  9982.      shell> mysql -u root
  9983.      mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('NEWPWD');
  9984.      mysql> SET PASSWORD FOR 'root'@'%' = PASSWORD('NEWPWD');
  9985.  
  9986. For Unix, do this:
  9987.  
  9988.      shell> mysql -u root
  9989.      mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('NEWPWD');
  9990.      mysql> SET PASSWORD FOR 'root'@'HOST_NAME' = PASSWORD('NEWPWD');
  9991.  
  9992. In the second `SET PASSWORD' statement, replace HOST_NAME with the name
  9993. of the server host.  This is the same hostname that you used when you
  9994. assigned the anonymous account passwords.
  9995.  
  9996. To assign passwords to the `root' accounts using `mysqladmin', execute
  9997. the following commands:
  9998.  
  9999.      shell> mysqladmin -u root password "NEWPWD"
  10000.      shell> mysqladmin -u root -h HOST_NAME password "NEWPWD"
  10001.  
  10002. These commands apply both to Windows and to Unix.  In the second
  10003. command, replace HOST_NAME with the name of the server host.  The double
  10004. quotes around the password are not always necessary, but you should use
  10005. them if the password contains spaces or other characters that are
  10006. special to your command interpreter.
  10007.  
  10008. If you are using a server from a _very_ old version of MySQL, the
  10009. `mysqladmin' commands to set the password will fail with the message
  10010. `parse error near 'SET password''.  The solution to this problem is to
  10011. upgrade the server to a newer version of MySQL.
  10012.  
  10013. You can also use `UPDATE' to modify the `user' table directly.  The
  10014. following `UPDATE' statement assigns a password to both `root' accounts
  10015. at once:
  10016.  
  10017.      shell> mysql -u root
  10018.      mysql> UPDATE mysql.user SET Password = PASSWORD('NEWPWD')
  10019.          ->     WHERE User = 'root';
  10020.      mysql> FLUSH PRIVILEGES;
  10021.  
  10022. The `UPDATE' statement applies both to Windows and to Unix.
  10023.  
  10024. After the passwords have been set, you must supply the appropriate
  10025. password whenever you connect to the server.  For example, if you want
  10026. to use `mysqladmin' to shut down the server, you can do so using this
  10027. command:
  10028.  
  10029.      shell> mysqladmin -u root -p shutdown
  10030.      Enter password: (enter root password here)
  10031.  
  10032. *Note*: If you forget your `root' password after setting it up, the
  10033. procedure for resetting it is covered in *Note Resetting permissions::.
  10034.  
  10035. To set up new accounts, you can use the `GRANT' statement. For
  10036. instructions, see *Note Adding users::.
  10037.  
  10038. Upgrading/Downgrading MySQL
  10039. ===========================
  10040.  
  10041. As a general rule, we recommend that when upgrading from one release
  10042. series to another, you should go to the next series rather than
  10043. skipping a series. For example, if you currently are running MySQL 3.23
  10044. and wish to upgrade to a newer series, upgrade to MySQL 4.0 rather than
  10045. to 4.1 or 5.0.
  10046.  
  10047. The following items form a checklist of things you should do whenever
  10048. you perform an upgrade:
  10049.  
  10050.    * Read the upgrading section for the release series to which you are
  10051.      upgrading.  Read the change notes as well.  These provide
  10052.      information about new features you can use.  For example, before
  10053.      upgrading from MySQL 4.1 to 5.0, read the 5.0 upgrading section
  10054.      (*note Upgrading-from-4.1::) and read the 5.0 change notes (*note
  10055.      News::).
  10056.  
  10057.    * Before you do an upgrade, back up your databases.
  10058.  
  10059.    * If you are running MySQL Server on Windows, see *Note Windows
  10060.      upgrading::.
  10061.  
  10062.    * An upgrade may involve changes to the grant tables that are stored
  10063.      in the `mysql' database. Occasionally new columns or tables are
  10064.      added to support new features.  To take advantage of these
  10065.      features, be sure that your grant tables are up to date.  The
  10066.      upgrade procedure is described in *Note Upgrading-grant-tables::.
  10067.  
  10068.    * If you are using replication, see *Note Replication Upgrade:: for
  10069.      information on upgrading your replication setup.
  10070.  
  10071.    * If you install a MySQL-Max distribution that includes a server
  10072.      named `mysqld-max', then upgrade later to a non-Max version of
  10073.      MySQL, `mysqld_safe' will still attempt to run the old `mysqld-max'
  10074.      server.  If you perform such an upgrade, you should manually
  10075.      remove the old `mysqld-max' server to ensure that `mysqld_safe'
  10076.      runs the new `mysqld' server.
  10077.  
  10078.  
  10079. You can always move the MySQL format files and data files between
  10080. different versions on the same architecture as long as you stay within
  10081. versions for the same release series of MySQL. The current production
  10082. release series is 4.0. If you change the character set when running
  10083. MySQL, you must run `myisamchk -r -q --set-character-set=CHARSET' on
  10084. all `MyISAM' tables.  Otherwise, your indexes may not be ordered
  10085. correctly, because changing the character set may also change the sort
  10086. order.
  10087.  
  10088. If you upgrade or downgrade from one release series to another, there
  10089. may be incompatibilities in table storage formats. In this case, you
  10090. can use `mysqldump' to dump your tables before upgrading. After
  10091. upgrading, reload the dump file using `mysql' to re-create your tables.
  10092.  
  10093. If you are cautious about using new versions, you can always rename
  10094. your old `mysqld' before installing a newer one. For example, if you
  10095. are using MySQL 4.0.18 and want to upgrade to 4.1.1, rename your
  10096. current server from `mysqld' to `mysqld-4.0.18'.  If your new `mysqld'
  10097. then does something unexpected, you can simply shut it down and restart
  10098. with your old `mysqld'.
  10099.  
  10100. If, after an upgrade, you experience problems with recompiled client
  10101. programs, such as `Commands out of sync' or unexpected core dumps, you
  10102. probably have used old header or library files when compiling your
  10103. programs.  In this case, you should check the date for your `mysql.h'
  10104. file and `libmysqlclient.a' library to verify that they are from the new
  10105. MySQL distribution.  If not, recompile your programs with the new
  10106. headers and libraries.
  10107.  
  10108. If problems occur, such as that the new `mysqld' server doesn't want to
  10109. start or that you can't connect without a password, verify that you
  10110. don't have some old `my.cnf' file from your previous installation.  You
  10111. can check this with the `--print-defaults' option (for example, `mysqld
  10112. --print-defaults').  If this displays anything other than the program
  10113. name, you have an active `my.cnf' file that affects server or client
  10114. operation.
  10115.  
  10116. It is a good idea to rebuild and reinstall the Perl `DBD::mysql' module
  10117. whenever you install a new release of MySQL. The same applies to other
  10118. MySQL interfaces as well, such as the PHP `mysql' extension and the
  10119. Python `MySQLdb' module.
  10120.  
  10121. Upgrading from Version 4.1 to 5.0
  10122. ---------------------------------
  10123.  
  10124. In general, you should do the following when upgrading to MySQL 5.0
  10125. from 4.1:
  10126.  
  10127.    * Check the items in the change list found later in this section to
  10128.      see whether any of them might affect your applications.
  10129.  
  10130.    * Read the 5.0 news items to see what significant new features you
  10131.      can use in 5.0.  *Note News-5.0.x::.
  10132.  
  10133.    * If you are running MySQL Server on Windows, see *Note Windows
  10134.      upgrading::.  Also, two of the Windows MySQL servers were renamed.
  10135.      *Note Windows select server::.
  10136.  
  10137.    * MySQL 5.0 adds support for stored procedures. This support
  10138.      requires the `proc' table in the `mysql' database.  To create this
  10139.      file, you should run the `mysql_fix_privilege_tables' script as
  10140.      described in *Note Upgrading-grant-tables::.
  10141.  
  10142.    * MySQL 5.0 adds support for views. This support requires the extra
  10143.      privilege columns in the `user' and `db' tables in the `mysql'
  10144.      database.  To create these columns, you should run the
  10145.      `mysql_fix_privilege_tables' script as described in *Note
  10146.      Upgrading-grant-tables::.
  10147.  
  10148.    * If you are using replication, see *Note Replication Upgrade:: for
  10149.      information on upgrading your replication setup.
  10150.  
  10151.    * MySQL 5.0.2 adds several new SQL modes that allow stricter control
  10152.      over rejecting records that have invalid or missing values.  *Note
  10153.      Server SQL mode::.  *Note constraint invalid data::.  If you want
  10154.      to enable this control but continue to use MySQL's capability for
  10155.      storing incorrect dates such as `'2004-02-31'', you should start
  10156.      the server with `--sql_mode=TRADITIONAL,ALLOW_INVALID_DATES'.
  10157.  
  10158.    * As of MySQL 5.0.2, the `SCHEMA' and `SCHEMAS' keywords are
  10159.      accepted as synonyms for `DATABASE' and `DATABASES'.
  10160.  
  10161.    * The update log is removed in MySQL 5.0.
  10162.  
  10163.  
  10164. The following list describes changes that may affect applications and
  10165. that you should watch out for when upgrading to version 5.0:
  10166.  
  10167.    * The update log is removed, so if you enabled it in the past, you
  10168.      should enable the binary log instead.  *Note News-5.0.x::.
  10169.  
  10170.    * User variables now are not case sensitive. In MySQL 4.1, `SET @x =
  10171.      0; SET @X = 1; SELECT @x;' creates two variables and returns `0'.
  10172.      In MySQL 5.0, it creates one variable and returns `1'.
  10173.  
  10174.  
  10175. Upgrading from Version 4.0 to 4.1
  10176. ---------------------------------
  10177.  
  10178. In general, you should do the following when upgrading to MySQL 4.1
  10179. from 4.0:
  10180.  
  10181.    * Check the items in the change lists found later in this section to
  10182.      see whether any of them might affect your applications. Some of
  10183.      them result in incompatibilities with earlier versions.
  10184.  
  10185.    * Read the 4.1 news items to see what significant new features you
  10186.      can use in 4.1.  *Note News-4.1.x::.
  10187.  
  10188.    * Character set support has been improved. The server now supports
  10189.      multiple character sets.
  10190.  
  10191.    * *Important note:* MySQL 4.1 stores table names and column names in
  10192.      `UTF8'. If you have table names or column names that use
  10193.      characters outside of the standard 7-bit US-ASCII range, you may
  10194.      have to do a `mysqldump' of your tables in MySQL 4.0 and restore
  10195.      them after upgrading to MySQL 4.1.  The symptom for this problem
  10196.      is that you get a `table not found' error when trying to access
  10197.      your tables. In this case, you should be able to downgrade back to
  10198.      MySQL 4.0 and access your data.
  10199.  
  10200.    * If you are running MySQL Server on Windows, see *Note Windows
  10201.      upgrading::.
  10202.  
  10203.      *Important note:* Early alpha Windows distributions for MySQL 4.1
  10204.      do not contain an installer program.  See *Note Windows binary
  10205.      installation:: for instructions on how to install such a
  10206.      distribution.
  10207.  
  10208.    * After upgrading, update the grant tables to have the new longer
  10209.      `Password' column that is needed for more secure handling of
  10210.      passwords.  The procedure uses `mysql_fix_privilege_tables' and is
  10211.      described in *Note Upgrading-grant-tables::.  If you don't do
  10212.      this, MySQL will not us the new more secure protocol to
  10213.      authenticate.  Implications of the password-handling change for
  10214.      applications are given later in this section.
  10215.  
  10216.    * If you are using replication, see *Note Replication Upgrade:: for
  10217.      information on upgrading your replication setup.
  10218.  
  10219.    * The Berkeley DB table handler is updated to DB 4.1 (from 3.2)
  10220.      which has a new log format. If you have to downgrade back to 4.0
  10221.      you must use `mysqldump' to dump your `BDB' tables in text format
  10222.      and delete all `log.XXXXXXXXXX' files before you start MySQL 4.0
  10223.      and reload the data.
  10224.  
  10225.    * MySQL 4.1.3 introduces support for per-connection time zones.
  10226.      *Note Time zone support::. To enable recognition of named time
  10227.      zones, you should create the time zone tables in the `mysql'
  10228.      database.  For instructions, see *Note Post-installation::.
  10229.  
  10230.    * If you are using an old `DBD-mysql' module (`Msql-MySQL-modules')
  10231.      you have to upgrade to use the newer `DBD-mysql' module. Anything
  10232.      above `DBD-mysql' 2.xx should be fine.
  10233.  
  10234.      If you don't upgrade, some methods (such as `DBI->do()') will not
  10235.      notice error conditions correctly.
  10236.  
  10237.    * The `--defaults-file=option-file-name' option now will give an
  10238.      error if the option file doesn't exist.
  10239.  
  10240.    * Some notes about upgrading from MySQL 4.0 to MySQL 4.1 on Netware:
  10241.      Make sure to upgrade Perl and PHP versions. Download and install
  10242.      Perl module for MySQL 4.1 from
  10243.      `http://forge.novell.com/modules/xfmod/project/showfiles.php?group_id=1126'
  10244.      and PHP Extension for MySQL 4.1 from
  10245.      `http://forge.novell.com/modules/xfmod/project/showfiles.php?group_id=1078'.
  10246.  
  10247.  
  10248. Several visible behaviors have changed between MySQL 4.0 and MySQL 4.1
  10249. to fix some critical bugs and make MySQL more compatible with standard
  10250. SQL.  These changes may affect your applications.
  10251.  
  10252. Some of the 4.1 behaviors can be tested in 4.0 before performing a full
  10253. upgrade to 4.1. We have added to later MySQL 4.0 releases (from 4.0.12
  10254. on) a `--new' startup option for `mysqld'.  *Note Server options::.
  10255.  
  10256. This option gives you the 4.1 behavior for the most critical changes.
  10257. You can also enable these behaviors for a given client connection with
  10258. the `SET @@new=1' command, or turn them off if they are on with `SET
  10259. @@new=0'.
  10260.  
  10261. If you believe that some of the 4.1 changes will affect you, we
  10262. recommend that before upgrading to 4.1, you download the latest MySQL
  10263. 4.0 version and run it with the `--new' option by adding the following
  10264. to your config file:
  10265.  
  10266.      [mysqld-4.0]
  10267.      new
  10268.  
  10269. That way you can test the new behaviors in 4.0 to make sure that your
  10270. applications work with them. This will help you have a smooth, painless
  10271. transition when you perform a full upgrade to 4.1 later. Putting the
  10272. `--new' option in the `[mysqld-4.0]' option group ensures that you
  10273. don't accidentally later run the 4.1 version with the `--new' option.
  10274.  
  10275. The following lists describe changes that may affect applications and
  10276. that you should watch out for when upgrading to version 4.1:
  10277.  
  10278. *Server Changes:*
  10279.  
  10280.    * All tables and string columns now have a character set.  *Note
  10281.      Charset::.  Character set information is displayed by `SHOW CREATE
  10282.      TABLE' and `mysqldump'.  (MySQL versions 4.0.6 and above can read
  10283.      the new dump files; older versions cannot.)  This change should
  10284.      not affect applications that use only one character set.
  10285.  
  10286.    * If you have table columns that store character data represented in
  10287.      a character set that the 4.1 server now supports directly, you can
  10288.      convert the columns to the proper character set using the
  10289.      instructions in *Note Charset-conversion::.  Also, database,
  10290.      table, and column identifiers now are stored internally using
  10291.      Unicode (UTF8) regardless of the default character set.  *Note
  10292.      Legal names::.
  10293.  
  10294.    * *Incompatible change:* Starting from MySQL 4.1.3, `InnoDB' uses
  10295.      the same character set comparison functions as MySQL for
  10296.      non-`latin1_swedish_ci' character strings that are not `BINARY'.
  10297.      This changes the sorting order of space and characters with a code
  10298.      < ASCII(32) in those character sets.  For `latin1_swedish_ci'
  10299.      character strings and `BINARY' strings, `InnoDB' uses its own
  10300.      pad-spaces-at-end comparison method, which stays unchanged.  If
  10301.      you have an `InnoDB' table created with MySQL 4.1.2 or earlier,
  10302.      with an index on a non-`latin1' character set (in the case of
  10303.      4.1.0 and 4.1.1, with any character set) and the table contains
  10304.      any `CHAR'/`VARCHAR'/or `TEXT' columns that are not `BINARY' but
  10305.      may contain characters with a code < ASCII(32), then you should do
  10306.      `ALTER TABLE' or `OPTIMIZE' table on it to *regenerate the index,
  10307.      after upgrading to MySQL 4.1.3 or later*.
  10308.  
  10309.    * *Incompatible change:* MySQL now interprets length specifications
  10310.      in character column definitions in characters. (Earlier versions
  10311.      interpret them in bytes.)  For example, `CHAR(N)' now means N
  10312.      characters, not N bytes.
  10313.  
  10314.      For single-byte character sets, this change makes no difference.
  10315.      However, if you upgrade to MySQL 4.1 and configure the server to
  10316.      use a multi-byte character set, the apparent length of character
  10317.      columns will change. Suppose that a 4.0 table contains a `CHAR(8)'
  10318.      column used to store `ujis' characters. Eight bytes can store from
  10319.      two to four `ujis' characters.  If you upgrade to 4.1 and
  10320.      configure the server to use `ujis' as its default character set,
  10321.      the server interprets character column lengths based on the
  10322.      maximum size of a `ujis' character, which is three bytes.  The
  10323.      number of three-byte characters that fit in eight bytes is two.
  10324.      Consequently, if you use `SHOW CREATE TABLE' to view the table
  10325.      definition, MySQL displays `CHAR(2)'.  You can retrieve existing
  10326.      data from the table, but you will be able to store new values
  10327.      containing only up to two characters. To correct this issue, use
  10328.      `ALTER TABLE' to change the column definition. For example:
  10329.  
  10330.           ALTER TABLE TBL_NAME MODIFY COL_NAME CHAR(8);
  10331.  
  10332.    * The table definition format used in `.frm' files has changed
  10333.      slightly in 4.1.  MySQL 4.0 versions from 4.0.11 on can read the
  10334.      new `.frm' format directly, but older versions cannot.  If you
  10335.      need to move tables from 4.1 to a version earlier than 4.0.11, you
  10336.      should use `mysqldump'.  *Note `mysqldump': mysqldump.
  10337.  
  10338.    * *Important note:* If you upgrade to MySQL 4.1.1 or higher, it is
  10339.      difficult to downgrade back to 4.0 or 4.1.0! That is because, for
  10340.      earlier versions, `InnoDB' is not aware of multiple tablespaces.
  10341.  
  10342.    * *Incompatible change:* In connection with the support for
  10343.      per-connection time zones in MySQL 4.1.3, the `timezone' system
  10344.      variable was renamed to `system_time_zone'.
  10345.  
  10346.    * Windows servers now support connections from local clients using
  10347.      shared memory if run with the `--shared-memory' option.  If you
  10348.      are running multiple servers this way on the same Windows machine,
  10349.      you should use a different `--shared-memory-base-name' option for
  10350.      each server.
  10351.  
  10352.    * The interface to aggregated UDF functions has changed a bit. You
  10353.      must now declare a `xxx_clear()' function for each aggregate
  10354.      function `XXX()'.
  10355.  
  10356.  
  10357. *Client Changes:*
  10358.  
  10359.    * `mysqldump' now has the `--opt' and `--quote-names' options
  10360.      enabled by default. You can turn them off with `--skip-opt' and
  10361.      `--skip-quote-names'.
  10362.  
  10363.  
  10364. *SQL Changes:*
  10365.  
  10366.    * *Incompatible change:* In MySQL 4.1.2, the `Type' column in the
  10367.      output from `SHOW TABLE STATUS' was renamed to `Engine'.
  10368.  
  10369.    * *Incompatible change:* String comparison now works according to
  10370.      SQL standard: Instead of stripping end spaces before comparison,
  10371.      we now extend the shorter string with spaces.  The problem with
  10372.      this is that now `'a' > 'a\t'', which it wasn't before.  If you
  10373.      have any tables where you have a `CHAR' or `VARCHAR' column in
  10374.      which the last character in the column may be less than
  10375.      `ASCII(32)', you should use `REPAIR TABLE' or `myisamchk' to
  10376.      ensure that the table is correct.
  10377.  
  10378.    * When using multiple-table `DELETE' statements, you should use the
  10379.      alias of the tables from which you want to delete, not the actual
  10380.      table name.  For example, instead of doing this:
  10381.  
  10382.           DELETE test FROM test AS t1, test2 WHERE ...
  10383.  
  10384.      Do this:
  10385.  
  10386.           DELETE t1 FROM test AS t1, test2 WHERE ...
  10387.  
  10388.      This corrects a problem that was present in MySQL 4.0.
  10389.  
  10390.    * *Incompatible change:* `TIMESTAMP' is now returned as a string in
  10391.      `'YYYY-MM-DD HH:MM:SS'' format (from 4.0.12 the `--new' option can
  10392.      be used to make a 4.0 server behave as 4.1 in this respect).
  10393.      *Note `TIMESTAMP' 4.1: TIMESTAMP 4.1.
  10394.  
  10395.      If you want to have the value returned as a number (as MySQL 4.0
  10396.      does) you should add `+0' to `TIMESTAMP' columns when you retrieve
  10397.      them:
  10398.  
  10399.           mysql> SELECT ts_col + 0 FROM TBL_NAME;
  10400.  
  10401.      Display widths for `TIMESTAMP' columns are no longer supported.
  10402.      For example, if you declare a column as `TIMESTAMP(10)', the `(10)'
  10403.      is ignored.
  10404.  
  10405.      These changes were necessary for SQL standards compliance. In a
  10406.      future version, a further change will be made (backward compatible
  10407.      with this change), allowing the timestamp length to indicate the
  10408.      desired number of digits for fractions of a second.
  10409.  
  10410.    * *Incompatible change:* Binary values such as `0xFFDF' now are
  10411.      assumed to be strings instead of numbers.  This fixes some
  10412.      problems with character sets where it's convenient to input a
  10413.      string as a binary value.  With this change, you should use
  10414.      `CAST()' if you want to compare binary values numerically as
  10415.      integers:
  10416.  
  10417.           mysql> SELECT CAST(0xFEFF AS UNSIGNED INTEGER)
  10418.               ->        < CAST(0xFF AS UNSIGNED INTEGER);
  10419.                   -> 0
  10420.  
  10421.      If you don't use `CAST()', a lexical string comparison will be
  10422.      done:
  10423.  
  10424.           mysql> SELECT 0xFEFF < 0xFF;
  10425.                   -> 1
  10426.  
  10427.      Using binary items in a numeric context or comparing them using the
  10428.      `=' operator should work as before.  (The `--new' option can be
  10429.      used from 4.0.13 on to make a 4.0 server behave as 4.1 in this
  10430.      respect.)
  10431.  
  10432.    * For functions that produce a `DATE', `DATETIME', or `TIME' value,
  10433.      the result returned to the client now is fixed up to have a
  10434.      temporal type. For example, in MySQL 4.1, you get this result:
  10435.  
  10436.           mysql> SELECT CAST('2001-1-1' AS DATETIME);
  10437.                  -> '2001-01-01 00:00:00'
  10438.  
  10439.      In MySQL 4.0, the result is different:
  10440.  
  10441.           mysql> SELECT CAST('2001-1-1' AS DATETIME);
  10442.                  -> '2001-01-01'
  10443.  
  10444.    * `DEFAULT' values no longer can be specified for `AUTO_INCREMENT'
  10445.      columns. (In 4.0, a `DEFAULT' value is silently ignored; in 4.1,
  10446.      an error occurs.)
  10447.  
  10448.    * `LIMIT' no longer accepts negative arguments.  Use some large
  10449.      number (maximum 18446744073709551615) instead of -1.
  10450.  
  10451.    * `SERIALIZE' is no longer a valid mode value for the `sql_mode'
  10452.      variable.  You should use `SET TRANSACTION ISOLATION LEVEL
  10453.      SERIALIZABLE' instead. `SERIALIZE' is no longer valid for the
  10454.      `--sql-mode' option for `mysqld', either. Use
  10455.      `--transaction-isolation=SERIALIZABLE' instead.
  10456.  
  10457.  
  10458. *C API Changes:*
  10459.  
  10460.    * *Incompatible change:* The `mysql_shutdown()' C API function has
  10461.      an extra parameter as of MySQL 4.1.3: `SHUTDOWN'-level. You should
  10462.      convert any `mysql_shutdown(X)' call you have in your application
  10463.      to `mysql_shutdown(X,SHUTDOWN_DEFAULT)'.
  10464.  
  10465.    * Some C API calls such as `mysql_real_query()' now return `1' on
  10466.      error, not `-1'.  You may have to change some old applications if
  10467.      they use constructs like this:
  10468.  
  10469.           if (mysql_real_query(mysql_object, query, query_length) == -1)
  10470.           {
  10471.             printf("Got error");
  10472.           }
  10473.  
  10474.      Change the call to test for a non-zero value instead:
  10475.  
  10476.           if (mysql_real_query(mysql_object, query, query_length) != 0)
  10477.           {
  10478.             printf("Got error");
  10479.           }
  10480.  
  10481.  
  10482. *Password-Handling Changes:*
  10483.  
  10484. The password hashing mechanism has changed in 4.1 to provide better
  10485. security, but this may cause compatibility problems if you still have
  10486. clients that use the client library from 4.0 or earlier.  (It is very
  10487. likely that you will have 4.0 clients in situations where clients
  10488. connect from remote hosts that have not yet upgraded to 4.1.)  The
  10489. following list indicates some possible upgrade strategies.  They
  10490. represent various tradeoffs between the goal of compatibility with old
  10491. clients and the goal of security.
  10492.  
  10493.    * Only upgrade the client to use 4.1 client libraries (not the
  10494.      server). No behavior will change (except the return value of some
  10495.      API calls), but you cannot use any of the new features provided by
  10496.      the 4.1 client/server protocol, either.  (MySQL 4.1 has an
  10497.      extended client/server protocol that offers such features as
  10498.      prepared statements and multiple result sets.)  *Note C API
  10499.      Prepared statements::.
  10500.  
  10501.    * Upgrade to 4.1 and run the `mysql_fix_privilege_tables' script to
  10502.      widen the `Password' column in the `user' table so that it can
  10503.      hold long password hashes.  But run the server with the
  10504.      `--old-passwords' option to provide backward compatibility that
  10505.      allows pre-4.1 clients to continue to connect to their short-hash
  10506.      accounts.  Eventually, when all your clients are upgraded to 4.1,
  10507.      you can stop using the `--old-passwords' server option. You can
  10508.      also change the passwords for your MySQL accounts to use the new
  10509.      more secure format.
  10510.  
  10511.    * Upgrade to 4.1 and run the `mysql_fix_privilege_tables' script to
  10512.      widen the `Password' column in the `user' table.  If you know that
  10513.      all clients also have been upgraded to 4.1, don't run the server
  10514.      with the `--old-passwords' option.  Instead, change the passwords
  10515.      on all existing accounts so that they have the new format.  A
  10516.      pure-4.1 installation is the most secure.
  10517.  
  10518.    * Some notes about upgrading from MySQL 4.0 to MySQL 4.1 on Netware:
  10519.      Make sure to upgrade Perl and PHP versions. Download Perl 5 for
  10520.      Netware from http://forge.novell.com/modules/xfmod/project/?perl5)
  10521.      and PHP from http://forge.novell.com/modules/xfmod/project/?php.
  10522.  
  10523.  
  10524. Further background on password hashing with respect to client
  10525. authentication and password-changing operations may be found in *Note
  10526. Password hashing:: and *Note Old client::.
  10527.  
  10528. Upgrading from Version 3.23 to 4.0
  10529. ----------------------------------
  10530.  
  10531. In general, you should do the following when upgrading to MySQL 4.0
  10532. from 3.23:
  10533.  
  10534.    * Check the items in the change lists found later in this section to
  10535.      see whether any of them might affect your applications.
  10536.  
  10537.    * Read the 4.0 news items to see what significant new features you
  10538.      can use in 4.0.  *Note News-4.0.x::.
  10539.  
  10540.    * If you are running MySQL Server on Windows, see *Note Windows
  10541.      upgrading::.
  10542.  
  10543.    * After upgrading, update the grant tables to add new privileges and
  10544.      features.  The procedure uses the `mysql_fix_privilege_tables'
  10545.      script and is described in *Note Upgrading-grant-tables::.
  10546.  
  10547.    * If you are using replication, see *Note Replication Upgrade:: for
  10548.      information on upgrading your replication setup.
  10549.  
  10550.    * Edit any MySQL startup scripts or option files to not use any of
  10551.      the deprecated options described later in this section.
  10552.  
  10553.    * Convert your old `ISAM' files to `MyISAM' files. One way to do this
  10554.      is with the `mysql_convert_table_format' script. (This is a Perl
  10555.      script; it requires that DBI be installed.) To convert the tables
  10556.      in a given database, use this command:
  10557.  
  10558.           shell> mysql_convert_table_format database DB_NAME
  10559.  
  10560.      Note that this should be used only if all tables in the given
  10561.      database are `ISAM' or `MyISAM' tables. To avoid converting tables
  10562.      of other types to `MyISAM', you can explicitly list the names of
  10563.      your `ISAM' tables after the database name on the command line.
  10564.  
  10565.      Individual tables can be changed to `MyISAM' by using the following
  10566.      `ALTER TABLE' statement for each table to be converted:
  10567.  
  10568.           mysql> ALTER TABLE TBL_NAME TYPE=MyISAM;
  10569.  
  10570.      If you are not sure of the table type for a given table, use this
  10571.      statement:
  10572.  
  10573.           mysql> SHOW TABLE STATUS LIKE 'TBL_NAME';
  10574.  
  10575.    * Ensure that you don't have any MySQL clients that use shared
  10576.      libraries (like the Perl `DBD::mysql' module). If you do, you
  10577.      should recompile them, because the data structures used in
  10578.      `libmysqlclient.so' have changed.  The same applies to other MySQL
  10579.      interfaces as well, such as the Python `MySQLdb' module.
  10580.  
  10581.  
  10582. MySQL 4.0 will work even if you don't perform the preceding actions,
  10583. but you will not be able to use the new security privileges in MySQL
  10584. 4.0 and you may run into problems when upgrading later to MySQL 4.1 or
  10585. newer.  The `ISAM' file format still works in MySQL 4.0, but is
  10586. deprecated and is not compiled in by default as of MySQL 4.1. `MyISAM'
  10587. tables should be used instead.
  10588.  
  10589. Old clients should work with a MySQL 4.0 server without any problems.
  10590.  
  10591. Even if you perform the preceding actions, you can still downgrade to
  10592. MySQL 3.23.52 or newer if you run into problems with the MySQL 4.0
  10593. series.  In this case, you must use `mysqldump' to dump any tables that
  10594. use full-text indexes and reload the dump file into the 3.23 server.
  10595. This is necessary because 4.0 uses a new format for full-text indexing.
  10596.  
  10597. The following lists describe changes that may affect applications and
  10598. that you should watch out for when upgrading to version 4.0:
  10599.  
  10600. *Server Changes:*
  10601.  
  10602.    * MySQL 4.0 has a lot of new privileges in the `mysql.user' table.
  10603.      *Note Privileges provided::.
  10604.  
  10605.      To get these new privileges to work, you must update the grant
  10606.      tables.  The procedure is described in *Note
  10607.      Upgrading-grant-tables::.  Until you do this, all accounts have
  10608.      the `SHOW DATABASES', `CREATE TEMPORARY TABLES', and `LOCK TABLES'
  10609.      privileges. `SUPER' and `EXECUTE' privileges take their value from
  10610.      `PROCESS'.  `REPLICATION SLAVE' and `REPLICATION CLIENT' take their
  10611.      values from `FILE'.
  10612.  
  10613.      If you have any scripts that create new MySQL user accounts, you
  10614.      may want to change them to use the new privileges.  If you are not
  10615.      using `GRANT' commands in the scripts, this is a good time to
  10616.      change your scripts to use `GRANT' instead of modifying the grant
  10617.      tables directly.
  10618.  
  10619.      From version 4.0.2 on, the option `--safe-show-database' is
  10620.      deprecated (and no longer does anything). *Note Privileges
  10621.      options::.
  10622.  
  10623.      If you get `Access denied' errors for new users in version 4.0.2
  10624.      and up, you should check whether you need some of the new grants
  10625.      that you didn't need before.  In particular, you will need
  10626.      `REPLICATION SLAVE' (instead of `FILE') for new slave servers.
  10627.  
  10628.    * `safe_mysqld' has been renamed to `mysqld_safe'.  For backward
  10629.      compatibility, binary distributions will for some time include
  10630.      `safe_mysqld' as a symlink to `mysqld_safe'.
  10631.  
  10632.    * `InnoDB' support is now included by default in binary
  10633.      distributions.  If you build MySQL from source, `InnoDB' is
  10634.      configured in by default.  If you do not use `InnoDB' and want to
  10635.      save memory when running a server that has `InnoDB' support
  10636.      enabled, use the `--skip-innodb' server startup option. To compile
  10637.      MySQL without `InnoDB' support, run `configure' with the
  10638.      `--without-innodb' option.
  10639.  
  10640.    * Values for the startup parameters
  10641.      `myisam_max_extra_sort_file_size' and
  10642.      `myisam_max_extra_sort_file_size' now are given in bytes (they
  10643.      were given in megabytes before 4.0.3).
  10644.  
  10645.    * `mysqld' now has the option `--temp-pool' enabled by default
  10646.      because this gives better performance with some operating systems
  10647.      (most notably Linux).
  10648.  
  10649.    * The `mysqld' startup options `--skip-locking' and
  10650.      `--enable-locking' were renamed to `--skip-external-locking' and
  10651.      `--external-locking'.
  10652.  
  10653.    * External system locking of `MyISAM'/`ISAM' files is now turned off
  10654.      by default.  You can turn this on with `--external-locking'.
  10655.      (However, this is never needed for most users.)
  10656.  
  10657.    * The following startup variables and options have been renamed:
  10658.  
  10659.      *Old Name*                         *New Name*
  10660.      `myisam_bulk_insert_tree_size'     `bulk_insert_buffer_size'
  10661.      `query_cache_startup_type'         `query_cache_type'
  10662.      `record_buffer'                    `read_buffer_size'
  10663.      `record_rnd_buffer'                `read_rnd_buffer_size'
  10664.      `sort_buffer'                      `sort_buffer_size'
  10665.      `warnings'                         `log-warnings'
  10666.      `--err-log'                        `--log-error' (for `mysqld_safe')
  10667.  
  10668.      The startup options `record_buffer', `sort_buffer', and `warnings'
  10669.      will still work in MySQL 4.0 but are deprecated.
  10670.  
  10671. *SQL Changes:*
  10672.  
  10673.    * The following SQL variables have been renamed:
  10674.  
  10675.      *Old Name*                         *New Name*
  10676.      `SQL_BIG_TABLES'                   `BIG_TABLES'
  10677.      `SQL_LOW_PRIORITY_UPDATES'         `LOW_PRIORITY_UPDATES'
  10678.      `SQL_MAX_JOIN_SIZE'                `MAX_JOIN_SIZE'
  10679.      `SQL_QUERY_CACHE_TYPE'             `QUERY_CACHE_TYPE'
  10680.      The old names still work in MySQL 4.0 but are deprecated.
  10681.  
  10682.    * You have to use `SET GLOBAL SQL_SLAVE_SKIP_COUNTER=skip_count'
  10683.      instead of `SET SQL_SLAVE_SKIP_COUNTER=skip_count'.
  10684.  
  10685.    * `SHOW MASTER STATUS' now returns an empty set if binary logging is
  10686.      not enabled.
  10687.  
  10688.    * `SHOW SLAVE STATUS' now returns an empty set if the slave is not
  10689.      initialized.
  10690.  
  10691.    * `SHOW INDEX' has two more columns than it had in 3.23 (`Null' and
  10692.      `Index_type').
  10693.  
  10694.    * The format of `SHOW OPEN TABLES' has changed.
  10695.  
  10696.    * `ORDER BY col_name DESC' sorts `NULL' values last, as of MySQL
  10697.      4.0.11. In 3.23 and in earlier 4.0 versions, this was not always
  10698.      consistent.
  10699.  
  10700.    * `CHECK', `LOCALTIME', and `LOCALTIMESTAMP' now are reserved words.
  10701.  
  10702.    * `DOUBLE' and `FLOAT' columns now honor the `UNSIGNED' flag on
  10703.      storage (before, `UNSIGNED' was ignored for these columns).
  10704.  
  10705.    * The result of all bitwise operators (`|', `&', `<<', `>>', and
  10706.      `~') is now unsigned.  This may cause problems if you are using
  10707.      them in a context where you want a signed result.  *Note Cast
  10708.      Functions::.
  10709.  
  10710.      *Note*: When you use subtraction between integer values where one
  10711.      is of type `UNSIGNED', the result will be unsigned.  In other
  10712.      words, before upgrading to MySQL 4.0, you should check your
  10713.      application for cases in which you are subtracting a value from an
  10714.      unsigned entity and want a negative answer or subtracting an
  10715.      unsigned value from an integer column. You can disable this
  10716.      behavior by using the `--sql-mode=NO_UNSIGNED_SUBTRACTION' option
  10717.      when starting `mysqld'.  *Note Server SQL mode::.
  10718.  
  10719.    * You should use integers to store values in `BIGINT' columns
  10720.      (instead of using strings, as you did in MySQL 3.23).  Using
  10721.      strings will still work, but using integers is more efficient.
  10722.  
  10723.    * In MySQL 3.23, `INSERT INTO ... SELECT' always had `IGNORE'
  10724.      enabled.  As of 4.0.1, MySQL will stop (and possibly roll back) by
  10725.      default in case of an error unless you specify `IGNORE'.
  10726.  
  10727.    * You should use `TRUNCATE TABLE' when you want to delete all rows
  10728.      from a table and you don't need to obtain a count of the number of
  10729.      rows that were deleted.  (`DELETE FROM TBL_NAME' returns a row
  10730.      count in 4.0 and doesn't reset the `AUTO_INCREMENT' counter, and
  10731.      `TRUNCATE TABLE' is faster.)
  10732.  
  10733.    * You will get an error if you have an active transaction or `LOCK
  10734.      TABLES' statement when trying to execute `TRUNCATE TABLE' or `DROP
  10735.      DATABASE'.
  10736.  
  10737.    * To use `MATCH ... AGAINST (... IN BOOLEAN MODE)' full-text searches
  10738.      with your tables, you must rebuild their indexes with `REPAIR TABLE
  10739.      tbl_name USE_FRM'.  If you attempt a boolean full-text search
  10740.      without rebuilding the indexes this way, the search will return
  10741.      incorrect results.  *Note Fulltext Fine-tuning::.
  10742.  
  10743.    * `LOCATE()' and `INSTR()' are case sensitive if one of the
  10744.      arguments is a binary string. Otherwise they are case insensitive.
  10745.  
  10746.    * `STRCMP()' now uses the current character set when performing
  10747.      comparisons.  This makes the default comparison behavior not case
  10748.      sensitive unless one or both of the operands are binary strings.
  10749.  
  10750.    * `HEX(STR)' now returns the characters in STR converted to
  10751.      hexadecimal.  If you want to convert a number to hexadecimal, you
  10752.      should ensure that you call `HEX()' with a numeric argument.
  10753.  
  10754.    * `RAND(seed)' returns a different random number series in 4.0 than
  10755.      in 3.23; this was done to further differentiate `RAND(seed)' and
  10756.      `RAND(seed+1)'.
  10757.  
  10758.    * The default type returned by `IFNULL(A,B)' is now set to be the
  10759.      more "general" of the types of `A' and `B'. (The
  10760.      general-to-specific order is string, `REAL', `INTEGER').
  10761.  
  10762.  
  10763. *C API Changes:*
  10764.  
  10765.    * The old C API functions `mysql_drop_db()', `mysql_create_db()', and
  10766.      `mysql_connect()' are no longer supported unless you compile MySQL
  10767.      with `CFLAGS=-DUSE_OLD_FUNCTIONS'.  However, it is preferable to
  10768.      change client programs to use the new 4.0 API instead.
  10769.  
  10770.    * In the `MYSQL_FIELD' structure, `length' and `max_length' have
  10771.      changed from `unsigned int' to `unsigned long'. This should not
  10772.      cause any problems, except that they may generate warning messages
  10773.      when used as arguments in the `printf()' class of functions.
  10774.  
  10775.    * Multi-threaded clients should use `mysql_thread_init()' and
  10776.      `mysql_thread_end()'. *Note Threaded clients::.
  10777.  
  10778.  
  10779. *Other Changes:*
  10780.  
  10781.    * If you want to recompile the Perl `DBD::mysql' module, use a recent
  10782.      version.  Version 2.9003 is recommended. Versions older than
  10783.      1.2218 should not be used because they use the deprecated
  10784.      `mysql_drop_db()' call.
  10785.  
  10786.  
  10787. Upgrading from Version 3.22 to 3.23
  10788. -----------------------------------
  10789.  
  10790. MySQL 3.22 and 3.21 clients will work without any problems with a MySQL
  10791. 3.23 server.
  10792.  
  10793. When upgrading to MySQL 3.23 from an earlier version, note the following
  10794. changes:
  10795.  
  10796. *Table Changes:*
  10797.  
  10798.    * MySQL 3.23 supports tables of the new `MyISAM' type and the old
  10799.      `ISAM' type.  By default, all new tables are created with type
  10800.      `MyISAM' unless you start `mysqld' with the
  10801.      `--default-table-type=isam' option.  You don't have to convert
  10802.      your old `ISAM' tables to use them with MySQL 3.23.  You can
  10803.      convert an `ISAM' table to `MyISAM' format with `ALTER TABLE
  10804.      TBL_NAME TYPE=MyISAM' or the Perl script
  10805.      `mysql_convert_table_format'.
  10806.  
  10807.    * All tables that use the `tis620' character set must be fixed with
  10808.      `myisamchk -r' or `REPAIR TABLE'.
  10809.  
  10810.    * If you are using the `german' character sort order for `ISAM'
  10811.      tables, you must repair them with `isamchk -r', because we have
  10812.      made some changes in the sort order.
  10813.  
  10814.  
  10815. *Client Program Changes:*
  10816.  
  10817.    * The MySQL client `mysql' is now by default started with the
  10818.      `--no-named-commands (-g)' option. This option can be disabled with
  10819.      `--enable-named-commands (-G)'. This may cause incompatibility
  10820.      problems in some cases--for example, in SQL scripts that use named
  10821.      commands without a semicolon.  Long format commands still work
  10822.      from the first line.
  10823.  
  10824.    * If you want your `mysqldump' files to be compatible between MySQL
  10825.      3.22 and 3.23, you should not use the `--opt' or `--all' option to
  10826.      `mysqldump'.
  10827.  
  10828.  
  10829. *SQL Changes:*
  10830.  
  10831.    * If you do a `DROP DATABASE' on a symbolically linked database,
  10832.      both the link and the original database are deleted.  This didn't
  10833.      happen in MySQL 3.22 because `configure' didn't detect the
  10834.      availability of the `readlink()' system call.
  10835.  
  10836.    * `OPTIMIZE TABLE' now works only for `MyISAM' tables.  For other
  10837.      table types, you can use `ALTER TABLE' to optimize the table.
  10838.      During `OPTIMIZE TABLE', the table is now locked to prevent it
  10839.      from being used by other threads.
  10840.  
  10841.    * Date functions that work on parts of dates (such as `MONTH()')
  10842.      will now return 0 for `0000-00-00' dates. In MySQL 3.22, these
  10843.      functions returned `NULL'.
  10844.  
  10845.    * The default return type of `IF()' now depends on both arguments,
  10846.      not just the first one.
  10847.  
  10848.    * `AUTO_INCREMENT' columns should not be used to store negative
  10849.      numbers. The reason for this is that negative numbers caused
  10850.      problems when wrapping from -1 to 0.  You should not store 0 in
  10851.      `AUTO_INCREMENT' columns, either; `CHECK TABLE' will complain
  10852.      about 0 values because they may change if you dump and restore the
  10853.      table.  `AUTO_INCREMENT' for `MyISAM' tables is now handled at a
  10854.      lower level and is much faster than before. In addition, for
  10855.      `MyISAM' tables, old numbers are no longer reused, even if you
  10856.      delete rows from the table.
  10857.  
  10858.    * `CASE', `DELAYED', `ELSE', `END', `FULLTEXT', `INNER', `RIGHT',
  10859.      `THEN', and `WHEN' now are reserved words.
  10860.  
  10861.    * `FLOAT(p)' now is a true floating-point type and not a value with a
  10862.      fixed number of decimals.
  10863.  
  10864.    * When declaring columns using a `DECIMAL(length,dec)' type, the
  10865.      `length' argument no longer includes a place for the sign or the
  10866.      decimal point.
  10867.  
  10868.    * A `TIME' string must now be of one of the following formats:
  10869.      `[[[DAYS] [H]H:]MM:]SS[.fraction]' or
  10870.      `[[[[[H]H]H]H]MM]SS[.fraction]'.
  10871.  
  10872.    * `LIKE' now compares strings using the same character comparison
  10873.      rules as for the `=' operator.  If you require the old behavior,
  10874.      you can compile MySQL with the `CXXFLAGS=-DLIKE_CMP_TOUPPER' flag.
  10875.  
  10876.    * `REGEXP' now is case insensitive if neither of the strings is a
  10877.      binary string.
  10878.  
  10879.    * When you check or repair `MyISAM' (`.MYI') tables, you should use
  10880.      the `CHECK TABLE' statement or the `myisamchk' command. For `ISAM'
  10881.      (`.ISM') tables, use the `isamchk' command.
  10882.  
  10883.    * Check all your calls to `DATE_FORMAT()' to make sure that there is
  10884.      a `%' before each format character.  (MySQL 3.22 already allowed
  10885.      this syntax, but now `%' is required.)
  10886.  
  10887.    * In MySQL 3.22, the output of `SELECT DISTINCT ...' was almost
  10888.      always sorted.  In MySQL 3.23, you must use `GROUP BY' or `ORDER
  10889.      BY' to obtain sorted output.
  10890.  
  10891.    * `SUM()' now returns `NULL' instead of 0 if there are no matching
  10892.      rows. This is required by standard SQL.
  10893.  
  10894.    * An `AND' or `OR' with `NULL' values will now return `NULL' instead
  10895.      of 0. This mostly affects queries that use `NOT' on an `AND/OR'
  10896.      expression as `NOT NULL' = `NULL'.
  10897.  
  10898.    * `LPAD()' and `RPAD()' now shorten the result string if it's longer
  10899.      than the length argument.
  10900.  
  10901.  
  10902. *C API Changes:*
  10903.  
  10904.    * `mysql_fetch_fields_direct()' now is a function instead of a macro.
  10905.      It now returns a pointer to a `MYSQL_FIELD' instead of a
  10906.      `MYSQL_FIELD'.
  10907.  
  10908.    * `mysql_num_fields()' no longer can be used on a `MYSQL*' object
  10909.      (it's now a function that takes a `MYSQL_RES*' value as an
  10910.      argument). With a `MYSQL*' object, you now should use
  10911.      `mysql_field_count()' instead.
  10912.  
  10913.  
  10914. Upgrading from Version 3.21 to 3.22
  10915. -----------------------------------
  10916.  
  10917. Nothing that affects compatibility has changed between versions 3.21
  10918. and 3.22.  The only pitfall is that new tables that are created with
  10919. `DATE' type columns will use the new way to store the date. You can't
  10920. access these new columns from an old version of `mysqld'.
  10921.  
  10922. When upgrading to MySQL 3.23 from an earlier version, note the following
  10923. changes:
  10924.  
  10925.    * After installing MySQL Version 3.22, you should start the new
  10926.      server and then run the `mysql_fix_privilege_tables' script. This
  10927.      will add the new privileges that you need to use the `GRANT'
  10928.      command.  If you forget this, you will get `Access denied' when
  10929.      you try to use `ALTER TABLE', `CREATE INDEX', or `DROP INDEX'. The
  10930.      procedure for updating the grant tables is described in *Note
  10931.      Upgrading-grant-tables::.
  10932.  
  10933.    * The C API interface to `mysql_real_connect()' has changed.  If you
  10934.      have an old client program that calls this function, you must pass
  10935.      a `0' for the new `db' argument (or recode the client to send the
  10936.      `db' element for faster connections).  You must also call
  10937.      `mysql_init()' before calling `mysql_real_connect()'.  This change
  10938.      was done to allow the new `mysql_options()' function to save
  10939.      options in the `MYSQL' handler structure.
  10940.  
  10941.    * The `mysqld' variable `key_buffer' has been renamed to
  10942.      `key_buffer_size', but you can still use the old name in your
  10943.      startup files.
  10944.  
  10945.  
  10946. Upgrading from Version 3.20 to 3.21
  10947. -----------------------------------
  10948.  
  10949. If you are running a version older than Version 3.20.28 and want to
  10950. switch to Version 3.21, you need to do the following:
  10951.  
  10952. You can start the `mysqld' Version 3.21 server with the
  10953. `--old-protocol' option to use it with clients from a Version 3.20
  10954. distribution.  In this case, the server uses the old pre-3.21
  10955. `password()' checking rather than the new method. Also, the new client
  10956. function `mysql_errno()' will not return any server error, only
  10957. `CR_UNKNOWN_ERROR'. The function does work for client errors.
  10958.  
  10959. If you are _not_ using the `--old-protocol' option to `mysqld', you
  10960. will need to make the following changes:
  10961.  
  10962.    * All client code must be recompiled. If you are using ODBC, you
  10963.      must get the MyODBC 2.x driver.
  10964.  
  10965.    * The `scripts/add_long_password' script must be run to convert the
  10966.      `Password' field in the `mysql.user' table to `CHAR(16)'.
  10967.  
  10968.    * All passwords must be reassigned in the `mysql.user' table to get
  10969.      62-bit rather than 31-bit passwords.
  10970.  
  10971.    * The table format hasn't changed, so you don't have to convert any
  10972.      tables.
  10973.  
  10974.  
  10975. MySQL 3.20.28 and above can handle the new `user' table format without
  10976. affecting clients. If you have a MySQL version earlier than 3.20.28,
  10977. passwords will no longer work with it if you convert the `user' table.
  10978. So to be safe, you should first upgrade to at least Version 3.20.28 and
  10979. then upgrade to Version 3.21.
  10980.  
  10981. The new client code works with a 3.20.x `mysqld' server, so if you
  10982. experience problems with 3.21.x, you can use the old 3.20.x server
  10983. without having to recompile the clients again.
  10984.  
  10985. If you are not using the `--old-protocol' option to `mysqld', old
  10986. clients will be unable to connect and will issue the following error
  10987. message:
  10988.  
  10989.      ERROR: Protocol mismatch. Server Version = 10 Client Version = 9
  10990.  
  10991. The Perl DBI interface also supports the old `mysqlperl' interface.
  10992. The only change you have to make if you use `mysqlperl' is to change
  10993. the arguments to the `connect()' function.  The new arguments are:
  10994. `host', `database', `user', and `password' (note that the `user' and
  10995. `password' arguments have changed places).
  10996.  
  10997. The following changes may affect queries in old applications:
  10998.  
  10999.    * `HAVING' must now be specified before any `ORDER BY' clause.
  11000.  
  11001.    * The parameters to `LOCATE()' have been swapped.
  11002.  
  11003.    * There are some new reserved words. The most noticeable are `DATE',
  11004.      `TIME', and `TIMESTAMP'.
  11005.  
  11006.  
  11007. Upgrading MySQL Under Windows
  11008. -----------------------------
  11009.  
  11010. When upgrading MySQL under Windows, please follow these steps:
  11011.  
  11012.   1. Download the latest Windows distribution of MySQL.
  11013.  
  11014.   2. Choose a time of day with low usage, where a maintenance break is
  11015.      acceptable.
  11016.  
  11017.   3. Alert the users who still are active about the maintenance break.
  11018.  
  11019.   4. Stop the running MySQL Server (for example, with `NET STOP MySQL'
  11020.      or with the `Services' utility if you are running MySQL as a
  11021.      service, or with `mysqladmin shutdown' otherwise).
  11022.  
  11023.   5. Exit the `WinMySQLAdmin' program if it is running.
  11024.  
  11025.   6. Run the installation script of the Windows distribution by
  11026.      clicking the Install button in WinZip and following the
  11027.      installation steps of the script.
  11028.  
  11029.      *Important note:* Early alpha Windows distributions for MySQL 4.1
  11030.      do not contain an installer program.  See *Note Windows binary
  11031.      installation:: for instructions on how to install such a
  11032.      distribution.
  11033.  
  11034.   7. You may either overwrite your old MySQL installation (usually
  11035.      located at `C:\mysql'), or install it into a different directory,
  11036.      such as `C:\mysql4'. Overwriting the old installation is
  11037.      recommended.
  11038.  
  11039.   8. Restart the server. For example, use `NET START MySQL' if you run
  11040.      MySQL as a service, or invoke `mysqld' directly otherwise.
  11041.  
  11042.   9. Update the grant tables. The procedure is described in *Note
  11043.      Upgrading-grant-tables::.
  11044.  
  11045.  
  11046. Possible error situations:
  11047.      A system error has occurred.
  11048.      System error 1067 has occurred.
  11049.      The process terminated unexpectedly.
  11050.  
  11051. These errors mean that your option file (by default `C:\my.cnf')
  11052. contains an option that cannot be recognized by MySQL. You can verify
  11053. that this is the case by trying to restart MySQL with the option file
  11054. renamed to prevent the server from using it. (For example, rename
  11055. `C:\my.cnf' to `C:\my_cnf.old'.)  Once you have verified it, you need
  11056. to identify which option is the culprit. Create a new `my.cnf' file and
  11057. move parts of the old file to it (restarting the server after you move
  11058. each part) until you determine which option causes server startup to
  11059. fail.
  11060.  
  11061. Upgrading the Grant Tables
  11062. --------------------------
  11063.  
  11064. Some releases introduce changes to the structure of the grant tables
  11065. (the tables in the `mysql' database) to add new  privileges or
  11066. features. To make sure that your grant tables are current when you
  11067. update to a new version of MySQL, you should update your grant tables
  11068. as well.
  11069.  
  11070. On Unix or Unix-like systems, update the grant tables by running the
  11071. `mysql_fix_privilege_tables' script:
  11072.  
  11073.      shell> mysql_fix_privilege_tables
  11074.  
  11075. You must run this script while the server is running. It attempts to
  11076. connect to the server running on the local host as `root'.  If your
  11077. `root' account requires a password, indicate the password on the
  11078. command line.  For MySQL 4.1 and up, specify the password like this:
  11079.  
  11080.      shell> mysql_fix_privilege_tables --password=root_password
  11081.  
  11082. Prior to MySQL 4.1, specify the password like this:
  11083.  
  11084.      shell> mysql_fix_privilege_tables root_password
  11085.  
  11086. The `mysql_fix_privilege_tables' script performs any actions necessary
  11087. to convert your grant tables to the current format. You might see some
  11088. `Duplicate column name' warnings as it runs; you can ignore them.
  11089.  
  11090. After running the script, stop the server and restart it.
  11091.  
  11092. On Windows systems, there isn't an easy way to update the grant tables
  11093. until MySQL 4.0.15.  From version 4.0.15 on, MySQL distributions
  11094. include a `mysql_fix_privilege_tables.sql' SQL script that you can run
  11095. using the `mysql' client.  If your MySQL installation is located at
  11096. `C:\mysql', the commands look like this:
  11097.  
  11098.      C:\> C:\mysql\bin\mysql -u root -p mysql
  11099.      mysql> SOURCE C:\mysql\scripts\mysql_fix_privilege_tables.sql
  11100.  
  11101. If your installation is located in some other directory, adjust the
  11102. pathnames appropriately.
  11103.  
  11104. The `mysql' command will prompt you for the `root' password; enter it
  11105. when prompted.
  11106.  
  11107. As with the Unix procedure, you might see some `Duplicate column name'
  11108. warnings as `mysql' processes the statements in the
  11109. `mysql_fix_privilege_tables.sql' script; you can ignore them.
  11110.  
  11111. After running the script, stop the server and restart it.
  11112.  
  11113. If you are upgrading to MySQL 5.0.1 or later, the grant table upgrade
  11114. procedure just described will add view-related columns for the `CREATE
  11115. VIEW' and `SHOW VIEW' privileges.  These privileges exist at the global
  11116. and database levels. Their initial values are assigned as follows:
  11117.  
  11118.    * In MySQL 5.0.2 or later, `mysql_fix_privilege_tables' copies the
  11119.      `Create_priv' value in the `user' table to the `Create_view_priv'
  11120.      and `Show_view_priv' columns.
  11121.  
  11122.    * In 5.0.1, the view-related privileges are not enabled for any
  11123.      accounts, so you cannot immediately use `GRANT' to give them give
  11124.      them to accounts that should have them. To deal with this, first
  11125.      connect to the server as `root' and issue the following statements
  11126.      to give the privileges to the `root' accounts manually with
  11127.      `UPDATE':
  11128.  
  11129.           mysql> UPDATE mysql.user SET Show_view_priv = 'Y', Create_view_priv = 'Y'
  11130.               -> WHERE User = 'root';
  11131.           mysql> FLUSH PRIVILEGES;
  11132.  
  11133.      After this, `root' can use `GRANT' to give the view privileges to
  11134.      other accounts. Note: You should issue the statements just shown,
  11135.      `GRANT ALL' will not work at the global and database levels,
  11136.      because `GRANT ALL' requires that you actually possess all
  11137.      privileges.
  11138.  
  11139.  
  11140. Copying MySQL Databases to Another Machine
  11141. ------------------------------------------
  11142.  
  11143. If you are using MySQL 3.23 or later, you can copy the `.frm', `.MYI',
  11144. and `.MYD' files for `MyISAM' tables between different architectures
  11145. that support the same floating-point format.  (MySQL takes care of any
  11146. byte-swapping issues.)  *Note `MyISAM' Tables: MyISAM.
  11147.  
  11148. The MySQL `ISAM' data and index files (`.ISD' and `*.ISM',
  11149. respectively) are architecture dependent and in some cases operating
  11150. system dependent.  If you want to move your applications to another
  11151. machine that has a different architecture or operating system than your
  11152. current machine, you should not try to move a database by simply copying
  11153. the files to the other machine. Use `mysqldump' instead.
  11154.  
  11155. By default, `mysqldump' will create a file containing SQL statements.
  11156. You can then transfer the file to the other machine and feed it as input
  11157. to the `mysql' client.
  11158.  
  11159. Try `mysqldump --help' to see what options are available.  If you are
  11160. moving the data to a newer version of MySQL, you should use `mysqldump
  11161. --opt' to take advantage of any optimizations that result in a dump
  11162. file that is smaller and can be processed faster.
  11163.  
  11164. The easiest (although not the fastest) way to move a database between
  11165. two machines is to run the following commands on the machine on which
  11166. the database is located:
  11167.  
  11168.      shell> mysqladmin -h 'OTHER_HOSTNAME' create DB_NAME
  11169.      shell> mysqldump --opt DB_NAME | mysql -h 'OTHER_HOSTNAME' DB_NAME
  11170.  
  11171. If you want to copy a database from a remote machine over a slow
  11172. network, you can use:
  11173.  
  11174.      shell> mysqladmin create DB_NAME
  11175.      shell> mysqldump -h 'OTHER_HOSTNAME' --opt --compress DB_NAME | mysql DB_NAME
  11176.  
  11177. You can also store the result in a file, then transfer the file to the
  11178. target machine and load the file into the database there.  For example,
  11179. you can dump a database to a file on the source machine like this:
  11180.  
  11181.      shell> mysqldump --quick DB_NAME | gzip > DB_NAME.CONTENTS.gz
  11182.  
  11183. (The file created in this example is compressed.) Transfer the file
  11184. containing the database contents to the target machine and run these
  11185. commands there:
  11186.  
  11187.      shell> mysqladmin create DB_NAME
  11188.      shell> gunzip < DB_NAME.CONTENTS.gz | mysql DB_NAME
  11189.  
  11190. You can also use `mysqldump' and `mysqlimport' to transfer the database.
  11191. For big tables, this is much faster than simply using `mysqldump'.  In
  11192. the following commands, `DUMPDIR' represents the full pathname of the
  11193. directory you use to store the output from `mysqldump'.
  11194.  
  11195. First, create the directory for the output files and dump the database:
  11196.  
  11197.      shell> mkdir DUMPDIR
  11198.      shell> mysqldump --tab=DUMPDIR DB_NAME
  11199.  
  11200. Then transfer the files in the `DUMPDIR' directory to some corresponding
  11201. directory on the target machine and load the files into MySQL there:
  11202.  
  11203.      shell> mysqladmin create DB_NAME           # create database
  11204.      shell> cat DUMPDIR/*.sql | mysql DB_NAME   # create tables in database
  11205.      shell> mysqlimport DB_NAME DUMPDIR/*.txt   # load data into tables
  11206.  
  11207. Also, don't forget to copy the `mysql' database because that is where
  11208. the `user', `db', and `host' grant tables are stored.  You might have
  11209. to run commands as the MySQL `root' user on the new machine until you
  11210. have the `mysql' database in place.
  11211.  
  11212. After you import the `mysql' database on the new machine, execute
  11213. `mysqladmin flush-privileges' so that the server reloads the grant table
  11214. information.
  11215.  
  11216. Operating System-Specific Notes
  11217. ===============================
  11218.  
  11219. Linux Notes
  11220. -----------
  11221.  
  11222. This section discusses issues that have been found to occur on Linux.
  11223. The first few subsections describe general operating system-related
  11224. issues, problems that can occur when using binary or source
  11225. distributions, and post-installation issues. The remaining subsections
  11226. discuss problems that occur with Linux on specific platforms.
  11227.  
  11228. Note that most of these problems occur on older versions of Linux. If
  11229. you are running a recent version, you likely will see none of them.
  11230.  
  11231. Linux Operating System Notes
  11232. ............................
  11233.  
  11234. MySQL needs at least Linux Version 2.0.
  11235.  
  11236. *Warning:* We have seen some strange problems with Linux 2.2.14 and
  11237. MySQL on SMP systems.  We also have reports from some MySQL users that
  11238. they have encountered serious stability problems using MySQL with
  11239. kernel 2.2.14.  If you are using this kernel, you should upgrade to
  11240. 2.2.19 (or newer) or to a 2.4 kernel.  If you have a multiple-CPU box,
  11241. then you should seriously consider using 2.4 because it will give you a
  11242. significant speed boost.  Your system also will be more stable.
  11243.  
  11244. When using LinuxThreads, you will see a minimum of three `mysqld'
  11245. processes running.  These are in fact threads.  There will be one
  11246. thread for the LinuxThreads manager, one thread to handle connections,
  11247. and one thread to handle alarms and signals.
  11248.  
  11249. Linux Binary Distribution Notes
  11250. ...............................
  11251.  
  11252. The Linux-Intel binary and RPM releases of MySQL are configured for the
  11253. highest possible speed.  We are always trying to use the fastest stable
  11254. compiler available.
  11255.  
  11256. The binary release is linked with `-static', which means you do not
  11257. normally need to worry about which version of the system libraries you
  11258. have. You need not install LinuxThreads, either.  A program linked with
  11259. `-static' is slightly larger than a dynamically linked program, but
  11260. also slightly faster (3-5%).  However, one problem with a statically
  11261. linked program is that you can't use user-defined functions (UDFs).  If
  11262. you are going to write or use UDFs (this is something for C or C++
  11263. programmers only), you must compile MySQL yourself using dynamic
  11264. linking.
  11265.  
  11266. A known issue with binary distributions is that on older Linux systems
  11267. that use `libc' (such as Red Hat 4.x or Slackware), you will get some
  11268. non-fatal problems with hostname resolution. If your system uses `libc'
  11269. rather than `glibc2', you probably will encounter some difficulties
  11270. with hostname resolution and `getpwnam()'. This happens because `glibc'
  11271. unfortunately depends on some external libraries to implement hostname
  11272. resolution and `getpwent()', even when compiled with `-static'.  These
  11273. problems manifest themselves in two ways:
  11274.  
  11275.    * You probably will see  the following error message when you run
  11276.      `mysql_install_db':
  11277.  
  11278.           Sorry, the host 'XXXX' could not be looked up
  11279.  
  11280.      You can deal with this by executing `mysql_install_db --force',
  11281.      which will not execute the `resolveip' test in `mysql_install_db'.
  11282.      The downside is that you can't use hostnames in the grant tables:
  11283.      Except for `localhost', you must use IP numbers instead.  If you
  11284.      are using an old version of MySQL that doesn't support `--force',
  11285.      you must manually remove the `resolveip' test in `mysql_install'
  11286.      using an editor.
  11287.  
  11288.    * You also may see the following error when you try to run `mysqld'
  11289.      with the `--user' option:
  11290.  
  11291.           getpwnam: No such file or directory
  11292.  
  11293.      To work around this, start `mysqld' by using the `su' command
  11294.      rather than by specifying the `--user' option. This causes the
  11295.      system itself to change the user ID of the `mysqld' process so
  11296.      that `mysqld' need not do so.
  11297.  
  11298.  
  11299. Another solution, which solves both problems, is to not use a binary
  11300. distribution.  Get a MySQL source distribution (in RPM or `tar.gz'
  11301. format) and install that instead.
  11302.  
  11303. On some Linux 2.2 versions, you may get the error `Resource temporarily
  11304. unavailable' when clients make a lot of new connections to a `mysqld'
  11305. server over TCP/IP.  The problem is that Linux has a delay between the
  11306. time that you close a TCP/IP socket and the time that the system
  11307. actually frees it.  There is room for only a finite number of TCP/IP
  11308. slots, so you will encounter the resource-unavailable error if clients
  11309. attempt too many new TCP/IP connections during a short time. For
  11310. example, you may see the error when you run the MySQL `test-connect'
  11311. benchmark over TCP/IP.
  11312.  
  11313. We have inquired about this problem a few times on different Linux
  11314. mailing lists but have never been able to find a suitable resolution.
  11315. The only known "fix" is for the clients to use persistent connections,
  11316. or, if you are running the database server and clients on the same
  11317. machine, to use Unix socket file connections rather than TCP/IP
  11318. connections.
  11319.  
  11320. Linux Source Distribution Notes
  11321. ...............................
  11322.  
  11323. The following notes regarding `glibc' apply only to the situation when
  11324. you build MySQL yourself. If you are running Linux on an x86 machine,
  11325. in most cases it is much better for you to just use our binary. We link
  11326. our binaries against the best patched version of `glibc' we can come up
  11327. with and with the best compiler options, in an attempt to make it
  11328. suitable for a high-load server.  For a typical user, even for setups
  11329. with a lot of concurrent connections or tables exceeding the 2GB limit,
  11330. our binary is the best choice in most cases.  After reading the
  11331. following text, if you are in doubt about what to do, try our binary
  11332. first to see whether it meets your needs.  If you discover that it is
  11333. not good enough, then you may want to try your own build.  In that
  11334. case, we would appreciate a note about it so that we can build a better
  11335. binary next time.
  11336.  
  11337. MySQL uses LinuxThreads on Linux.  If you are using an old Linux
  11338. version that doesn't have `glibc2', you must install LinuxThreads
  11339. before trying to compile MySQL.   You can get LinuxThreads at
  11340. `http://dev.mysql.com/downloads/os-linux.html'.
  11341.  
  11342. Note that `glibc' versions before and including Version 2.1.1 have a
  11343. fatal bug in `pthread_mutex_timedwait()' handling, which is used when
  11344. you issue `INSERT DELAYED' statements.  We recommend that you not use
  11345. `INSERT DELAYED' before upgrading `glibc'.
  11346.  
  11347. Note that Linux kernel and the LinuxThread library can by default only
  11348. have 1,024 threads.  If you plan to have more than 1,000 concurrent
  11349. connections, you will need to make some changes to LinuxThreads:
  11350.  
  11351.    * Increase `PTHREAD_THREADS_MAX' in
  11352.      `sysdeps/unix/sysv/linux/bits/local_lim.h' to 4096 and decrease
  11353.      `STACK_SIZE' in `linuxthreads/internals.h' to 256KB. The paths are
  11354.      relative to the root of `glibc'. (Note that MySQL will not be
  11355.      stable with around 600-1000 connections if `STACK_SIZE' is the
  11356.      default of 2MB.)
  11357.  
  11358.    * Recompile LinuxThreads to produce a new `libpthread.a' library,
  11359.      and relink MySQL against it.
  11360.  
  11361.  
  11362. The page `http://www.volano.com/linuxnotes.html' contains additional
  11363. information about circumventing thread limits in LinuxThreads.
  11364.  
  11365. There is another issue that greatly hurts MySQL performance, especially
  11366. on SMP systems.  The mutex implementation in LinuxThreads in `glibc'
  11367. 2.1 is very bad for programs with many threads that hold the mutex only
  11368. for a short time.  This produces a paradoxical result: If you link
  11369. MySQL against an unmodified LinuxThreads, removing processors from an
  11370. SMP actually improves MySQL performance in many cases.  We have made a
  11371. patch available for `glibc' 2.1.3 to correct this behavior
  11372. (`http://www.mysql.com/Downloads/Linux/linuxthreads-2.1-patch').
  11373.  
  11374. With `glibc' 2.2.2, MySQL 3.23.36 will use the adaptive mutex, which is
  11375. much better than even the patched one in `glibc' 2.1.3. Be warned,
  11376. however, that under some conditions, the current mutex code in `glibc'
  11377. 2.2.2 overspins, which hurts MySQL performance. The likelihood that
  11378. this condition will occur can be reduced by renicing the `mysqld'
  11379. process to the highest priority. We have also been able to correct the
  11380. overspin behavior with a patch, available at
  11381. `http://www.mysql.com/Downloads/Linux/linuxthreads-2.2.2.patch'.  It
  11382. combines the correction of overspin, maximum number of threads, and
  11383. stack spacing all in one. You will need to apply it in the
  11384. `linuxthreads' directory with `patch -p0
  11385. </tmp/linuxthreads-2.2.2.patch'.  We hope it will be included in some
  11386. form in future releases of `glibc' 2.2. In any case, if you link
  11387. against `glibc' 2.2.2, you still need to correct `STACK_SIZE' and
  11388. `PTHREAD_THREADS_MAX'. We hope that the defaults will be corrected to
  11389. some more acceptable values for high-load MySQL setup in the future, so
  11390. that the commands needed to produce your own build can be reduced to
  11391. `./configure; make; make install'.
  11392.  
  11393. We recommend that you use these patches to build a special static
  11394. version of `libpthread.a' and use it only for statically linking
  11395. against MySQL. We know that the patches are safe for MySQL and
  11396. significantly improve its performance, but we cannot say anything about
  11397. other applications. If you link other applications that require
  11398. LinuxThreads against the patched static version of the library, or
  11399. build a patched shared version and install it on your system, you do so
  11400. at your own risk.
  11401.  
  11402. If you experience any strange problems during the installation of
  11403. MySQL, or with some common utilities hanging, it is very likely that
  11404. they are either library or compiler related. If this is the case, using
  11405. our binary will resolve them.
  11406.  
  11407. If you link your own MySQL client programs, you may see the following
  11408. error at runtime:
  11409.  
  11410.      ld.so.1: fatal: libmysqlclient.so.#:
  11411.      open failed: No such file or directory
  11412.  
  11413. This problem can be avoided by one of the following methods:
  11414.  
  11415.    * Link clients with the `-Wl,r/full/path/to/libmysqlclient.so' flag
  11416.      rather than with `-Lpath').
  11417.  
  11418.    * Copy `libmysqclient.so' to `/usr/lib'.
  11419.  
  11420.    * Add the pathname of the directory where `libmysqlclient.so' is
  11421.      located to the `LD_RUN_PATH' environment variable before running
  11422.      your client.
  11423.  
  11424. If you are using the Fujitsu compiler (`fcc/FCC'), you will have some
  11425. problems compiling MySQL because the Linux header files are very `gcc'
  11426. oriented.  The following `configure' line should work with `fcc/FCC':
  11427.  
  11428.      CC=fcc CFLAGS="-O -K fast -K lib -K omitfp -Kpreex -D_GNU_SOURCE \
  11429.          -DCONST=const -DNO_STRTOLL_PROTO" \
  11430.      CXX=FCC CXXFLAGS="-O -K fast -K lib \
  11431.          -K omitfp -K preex --no_exceptions --no_rtti -D_GNU_SOURCE \
  11432.          -DCONST=const -Dalloca=__builtin_alloca -DNO_STRTOLL_PROTO \
  11433.          '-D_EXTERN_INLINE=static __inline'" \
  11434.      ./configure \
  11435.          --prefix=/usr/local/mysql --enable-assembler \
  11436.          --with-mysqld-ldflags=-all-static --disable-shared \
  11437.          --with-low-memory
  11438.  
  11439. Linux Post-Installation Notes
  11440. .............................
  11441.  
  11442. `mysql.server' can be found in the `support-files' directory under the
  11443. MySQL installation directory or in a MySQL source tree.  You can install
  11444. it as `/etc/init.d/mysql' for automatic MySQL startup and shutdown.
  11445. *Note Automatic start::.
  11446.  
  11447. If MySQL can't open enough files or connections, it may be that you
  11448. haven't configured Linux to handle enough files.
  11449.  
  11450. In Linux 2.2 and onward, you can check the number of allocated file
  11451. handles as follows:
  11452.  
  11453.      shell> cat /proc/sys/fs/file-max
  11454.      shell> cat /proc/sys/fs/dquot-max
  11455.      shell> cat /proc/sys/fs/super-max
  11456.  
  11457. If you have more than 16MB of memory, you should add something like the
  11458. following to your init scripts (for example, `/etc/init.d/boot.local'
  11459. on SuSE Linux):
  11460.  
  11461.      echo 65536 > /proc/sys/fs/file-max
  11462.      echo 8192 > /proc/sys/fs/dquot-max
  11463.      echo 1024 > /proc/sys/fs/super-max
  11464.  
  11465. You can also run the `echo' commands from the command line as `root',
  11466. but these settings will be lost the next time your computer restarts.
  11467.  
  11468. Alternatively, you can set these parameters on startup by using the
  11469. `sysctl' tool, which is used by many Linux distributions (SuSE has
  11470. added it as well, beginning with SuSE Linux 8.0). Just put the following
  11471. values into a file named `/etc/sysctl.conf':
  11472.  
  11473.      # Increase some values for MySQL
  11474.      fs.file-max = 65536
  11475.      fs.dquot-max = 8192
  11476.      fs.super-max = 1024
  11477.  
  11478. You should also add the following to `/etc/my.cnf':
  11479.  
  11480.      [mysqld_safe]
  11481.      open-files-limit=8192
  11482.  
  11483. This should allow the server a limit of 8,192 for the combined number of
  11484. connections and open files.
  11485.  
  11486. The `STACK_SIZE' constant in LinuxThreads controls the spacing of thread
  11487. stacks in the address space.  It needs to be large enough so that there
  11488. will be plenty of room for each individual thread stack, but small
  11489. enough to keep the stack of some threads from running into the global
  11490. `mysqld' data.  Unfortunately, as we have experimentally discovered,
  11491. the Linux implementation of `mmap()' will successfully unmap an already
  11492. mapped region if you ask it to map out an address already in use,
  11493. zeroing out the data on the entire page instead of returning an error.
  11494. So, the safety of `mysqld' or any other threaded application depends on
  11495. "gentlemanly" behavior of the code that creates threads.  The user must
  11496. take measures to make sure that the number of running threads at any
  11497. time is sufficiently low for thread stacks to stay away from the global
  11498. heap.  With `mysqld', you should enforce this behavior by setting a
  11499. reasonable value for the `max_connections' variable.
  11500.  
  11501. If you build MySQL yourself, you can patch LinuxThreads for better
  11502. stack use.  *Note Source notes-Linux::.  If you do not want to patch
  11503. LinuxThreads, you should set `max_connections' to a value no higher
  11504. than 500.  It should be even less if you have a large key buffer,  large
  11505. heap tables, or some other things that make `mysqld' allocate a lot of
  11506. memory, or if you are running a 2.2 kernel with a 2GB patch. If you are
  11507. using our binary or RPM version 3.23.25 or later, you can safely set
  11508. `max_connections' at 1500, assuming no large key buffer or heap tables
  11509. with lots of data.  The more you reduce `STACK_SIZE' in LinuxThreads
  11510. the more threads you can safely create.  We recommend values between
  11511. 128KB and 256KB.
  11512.  
  11513. If you use a lot of concurrent connections, you may suffer from a
  11514. "feature" in the 2.2 kernel that attempts to prevent fork bomb attacks
  11515. by penalizing a process for forking or cloning a child.  This causes
  11516. MySQL not to scale well as you increase the number of concurrent
  11517. clients.  On single-CPU systems, we have seen this manifested as very
  11518. slow thread creation: It may take a long time to connect to MySQL (as
  11519. long as one minute), and it may take just as long to shut it down.  On
  11520. multiple-CPU systems, we have observed a gradual drop in query speed as
  11521. the number of clients increases.  In the process of trying to find a
  11522. solution, we have received a kernel patch from one of our users who
  11523. claimed it made a lot of difference for his site.  The patch is
  11524. available at `http://www.mysql.com/Downloads/Patches/linux-fork.patch'.
  11525. We have now done rather extensive testing of this patch on both
  11526. development and production systems.  It has significantly improved
  11527. MySQL performance without causing any problems and we now recommend it
  11528. to our users who still run high-load servers on 2.2 kernels.
  11529.  
  11530. This issue has been fixed in the 2.4 kernel, so if you are not satisfied
  11531. with the current performance of your system, rather than patching your
  11532. 2.2 kernel, it might be easier to upgrade to 2.4. On SMP systems,
  11533. upgrading also will give you a nice SMP boost in addition to fixing the
  11534. fairness bug.
  11535.  
  11536. We have tested MySQL on the 2.4 kernel on a two-CPU machine and found
  11537. MySQL scales _much_ better. There was virtually no slowdown on query
  11538. throughput all the way up to 1,000 clients, and the MySQL scaling factor
  11539. (computed as the ratio of maximum throughput to the throughput for one
  11540. client) was 180%.  We have observed similar results on a four-CPU
  11541. system: Virtually no slowdown as the number of clients was increased up
  11542. to 1,000, and a 300% scaling factor. Based on these results, for a
  11543. high-load SMP server using a 2.2 kernel, we definitely recommend
  11544. upgrading to the 2.4 kernel at this point.
  11545.  
  11546. We have discovered that it is essential to run the `mysqld' process
  11547. with the highest possible priority on the 2.4 kernel to achieve maximum
  11548. performance.  This can be done by adding a `renice -20 $$' command to
  11549. `mysqld_safe'. In our testing on a four-CPU machine, increasing the
  11550. priority resulted in a 60% throughput increase with 400 clients.
  11551.  
  11552. We are currently also trying to collect more information on how well
  11553. MySQL performs with a 2.4 kernel on four-way and eight-way systems. If
  11554. you have access such a system and have done some benchmarks, please
  11555. send an email message to <benchmarks@mysql.com> with the results. We
  11556. will review them for inclusion in the manual.
  11557.  
  11558. If you see a dead `mysqld' server process with `ps', this usually means
  11559. that you have found a bug in MySQL or you have a corrupted table. *Note
  11560. Crashing::.
  11561.  
  11562. To get a core dump on Linux if `mysqld' dies with a `SIGSEGV' signal,
  11563. you can start `mysqld' with the `--core-file' option.  Note that you
  11564. also probably need to raise the core file size by adding `ulimit -c
  11565. 1000000' to `mysqld_safe' or starting `mysqld_safe' with
  11566. `--core-file-size=1000000'.  *Note `mysqld_safe': mysqld_safe.
  11567.  
  11568. Linux x86 Notes
  11569. ...............
  11570.  
  11571. MySQL requires `libc' Version 5.4.12 or newer. It's known to work with
  11572. `libc' 5.4.46.  `glibc' Version 2.0.6 and later should also work. There
  11573. have been some problems with the `glibc' RPMs from Red Hat, so if you
  11574. have problems, check whether there are any updates.  The `glibc'
  11575. 2.0.7-19 and 2.0.7-29 RPMs are known to work.
  11576.  
  11577. If you are using Red Hat 8.0 or a new `glibc' 2.2.x library, you may see
  11578. `mysqld' die in `gethostbyaddr()'. This happens because the new `glibc'
  11579. library requires a stack size greater than 128KB for this call.  To fix
  11580. the problem, start `mysqld' with the `--thread-stack=192K' option.
  11581. (Use `-O thread_stack=192K' before MySQL 4.)  This stack size is now
  11582. the default on MySQL 4.0.10 and above, so you should not see the
  11583. problem.
  11584.  
  11585. If you are using `gcc' 3.0 and above to compile MySQL, you must install
  11586. the `libstdc++v3' library before compiling MySQL; if you don't do this,
  11587. you will get an error about a missing `__cxa_pure_virtual' symbol
  11588. during linking.
  11589.  
  11590. On some older Linux distributions, `configure' may produce an error
  11591. like this:
  11592.  
  11593.      Syntax error in sched.h. Change _P to __P in the
  11594.      /usr/include/sched.h file.
  11595.      See the Installation chapter in the Reference Manual.
  11596.  
  11597. Just do what the error message says. Add an extra underscore to the
  11598. `_P' macro name that has only one underscore, then try again.
  11599.  
  11600. You may get some warnings when compiling. Those shown here can be
  11601. ignored:
  11602.  
  11603.      mysqld.cc -o objs-thread/mysqld.o
  11604.      mysqld.cc: In function `void init_signals()':
  11605.      mysqld.cc:315: warning: assignment of negative value `-1' to
  11606.      `long unsigned int'
  11607.      mysqld.cc: In function `void * signal_hand(void *)':
  11608.      mysqld.cc:346: warning: assignment of negative value `-1' to
  11609.      `long unsigned int'
  11610.  
  11611. If `mysqld' always dumps core when it starts, the problem may be that
  11612. you have an old `/lib/libc.a'.  Try renaming it, then remove
  11613. `sql/mysqld' and do a new `make install' and try again.  This problem
  11614. has been reported on some Slackware installations.
  11615.  
  11616. If you get the following error when linking `mysqld', it means that
  11617. your `libg++.a' is not installed correctly:
  11618.  
  11619.      /usr/lib/libc.a(putc.o): In function `_IO_putc':
  11620.      putc.o(.text+0x0): multiple definition of `_IO_putc'
  11621.  
  11622. You can avoid using `libg++.a' by running `configure' like this:
  11623.  
  11624.      shell> CXX=gcc ./configure
  11625.  
  11626. If `mysqld' crashes immediately and you are running Red Hat Version 5.0
  11627. with a version of `glibc' older than 2.0.7-5, you should make sure that
  11628. you have installed all `glibc' patches.  There is a lot of information
  11629. about this in the MySQL mail archives, available online at
  11630. `http://lists.mysql.com/'.
  11631.  
  11632. Linux SPARC Notes
  11633. .................
  11634.  
  11635. In some implementations, `readdir_r()' is broken.  The symptom is that
  11636. the `SHOW DATABASES' statement always returns an empty set.  This can
  11637. be fixed by removing `HAVE_READDIR_R' from `config.h' after configuring
  11638. and before compiling.
  11639.  
  11640. Linux Alpha Notes
  11641. .................
  11642.  
  11643. MySQL 3.23.12 is the first MySQL version that is tested on Linux-Alpha.
  11644. If you plan to use MySQL on Linux-Alpha, you should ensure that you
  11645. have this version or newer.
  11646.  
  11647. We have tested MySQL on Alpha with our benchmarks and test suite, and
  11648. it appears to work nicely.
  11649.  
  11650. We currently build the MySQL binary packages on SuSE Linux 7.0 for AXP,
  11651. kernel 2.4.4-SMP, Compaq C compiler (V6.2-505) and Compaq C++ compiler
  11652. (V6.3-006) on a Compaq DS20 machine with an Alpha EV6 processor.
  11653.  
  11654. You can find the preceding compilers at
  11655. `http://www.support.compaq.com/alpha-tools/'.  By using these compilers
  11656. rather than `gcc', we get about 9-14% better MySQL performance.
  11657.  
  11658. Note that until MySQL version 3.23.52 and 4.0.2, we optimized the
  11659. binary for the current CPU only (by using the `-fast' compile option).
  11660. This means that for older versions, you can use our Alpha binaries only
  11661. if you have an Alpha EV6 processor.
  11662.  
  11663. For all following releases, we added the `-arch generic' flag to our
  11664. compile options, which makes sure that the binary runs on all Alpha
  11665. processors. We also compile statically to avoid library problems.  The
  11666. `configure' command looks like this:
  11667.  
  11668.      CC=ccc CFLAGS="-fast -arch generic" CXX=cxx \
  11669.      CXXFLAGS="-fast -arch generic -noexceptions -nortti" \
  11670.      ./configure --prefix=/usr/local/mysql --disable-shared \
  11671.          --with-extra-charsets=complex --enable-thread-safe-client \
  11672.          --with-mysqld-ldflags=-non_shared --with-client-ldflags=-non_shared
  11673.  
  11674. If you want to use `egcs', the following `configure' line worked for us:
  11675.  
  11676.      CFLAGS="-O3 -fomit-frame-pointer" CXX=gcc \
  11677.      CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors \
  11678.          -fno-exceptions -fno-rtti" \
  11679.      ./configure --prefix=/usr/local/mysql --disable-shared
  11680.  
  11681. Some known problems when running MySQL on Linux-Alpha:
  11682.  
  11683.    * Debugging threaded applications like MySQL will not work with `gdb
  11684.      4.18'.  You should use `gdb' 5.1 instead.
  11685.  
  11686.    * If you try linking `mysqld' statically when using `gcc', the
  11687.      resulting image will dump core at startup time.  In other words,
  11688.      _do not_ use `--with-mysqld-ldflags=-all-static' with `gcc'.
  11689.  
  11690. Linux PowerPC Notes
  11691. ...................
  11692.  
  11693. MySQL should work on MkLinux with the newest `glibc' package (tested
  11694. with `glibc' 2.0.7).
  11695.  
  11696. Linux MIPS Notes
  11697. ................
  11698.  
  11699. To get MySQL to work on Qube2 (Linux Mips), you need the newest `glibc'
  11700. libraries. `glibc-2.0.7-29C2' is known to work.  You must also use the
  11701. `egcs' C++ compiler (`egcs' 1.0.2-9, `gcc' 2.95.2 or newer).
  11702.  
  11703. Linux IA-64 Notes
  11704. .................
  11705.  
  11706. To get MySQL to compile on Linux IA-64, we use the following `configure'
  11707. command for building with `gcc' 2.96:
  11708.  
  11709.      CC=gcc \
  11710.      CFLAGS="-O3 -fno-omit-frame-pointer" \
  11711.      CXX=gcc \
  11712.      CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors \
  11713.          -fno-exceptions -fno-rtti" \
  11714.          ./configure --prefix=/usr/local/mysql \
  11715.          "--with-comment=Official MySQL binary" \
  11716.          --with-extra-charsets=complex
  11717.  
  11718. On IA-64, the MySQL client binaries use shared libraries. This means
  11719. that if you install our binary distribution at a location other than
  11720. `/usr/local/mysql', you need to add the path of the directory where you
  11721. have `libmysqlclient.so' installed either to the `/etc/ld.so.conf' file
  11722. or to the value of your `LD_LIBRARY_PATH' environment variable.
  11723.  
  11724. *Note Link errors::.
  11725.  
  11726. Mac OS X Notes
  11727. --------------
  11728.  
  11729. On Mac OS X, `tar' cannot handle long filenames. If you need to unpack a
  11730. `.tar.gz' distribution, use `gnutar' instead.
  11731.  
  11732. Mac OS X 10.x (Darwin)
  11733. ......................
  11734.  
  11735. MySQL should work without any problems on Mac OS X 10.x (Darwin).
  11736.  
  11737. Our binary for Mac OS X is compiled on Darwin 6.3 with the following
  11738. `configure' line:
  11739.  
  11740.      CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc \
  11741.      CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors \
  11742.          -fno-exceptions -fno-rtti" \
  11743.          ./configure --prefix=/usr/local/mysql \
  11744.          --with-extra-charsets=complex --enable-thread-safe-client \
  11745.          --enable-local-infile --disable-shared
  11746.  
  11747. *Note Mac OS X installation::.
  11748.  
  11749. Mac OS X Server 1.2 (Rhapsody)
  11750. ..............................
  11751.  
  11752. For current versions of Mac OS X Server, no operating system changes are
  11753. necessary before compiling MySQL.  Compiling for the Server platform is
  11754. the same as for the client version of Mac OS X. (However, note that
  11755. MySQL comes preinstalled on Mac OS X Server, so you need not build it
  11756. yourself.)
  11757.  
  11758. For older versions (Mac OS X Server 1.2, a.k.a. Rhapsody), you must
  11759. first install a pthread package before trying to configure MySQL.
  11760.  
  11761. *Note Mac OS X installation::.
  11762.  
  11763. Solaris Notes
  11764. -------------
  11765.  
  11766. On Solaris, you may run into trouble even before you get the MySQL
  11767. distribution unpacked!  Solaris `tar' can't handle long filenames, so
  11768. you may see an error like this when you unpack MySQL:
  11769.  
  11770.      x mysql-3.22.12-beta/bench/Results/ATIS-mysql_odbc-NT_4.0-cmp-db2,
  11771.      informix,ms-sql,mysql,oracle,solid,sybase, 0 bytes, 0 tape blocks
  11772.      tar: directory checksum error
  11773.  
  11774. In this case, you must use GNU `tar' (`gtar') to unpack the
  11775. distribution.  You can find a precompiled copy for Solaris at
  11776. `http://dev.mysql.com/downloads/os-solaris.html'.
  11777.  
  11778. Sun native threads work only on Solaris 2.5 and higher.  For Version
  11779. 2.4 and earlier, MySQL automatically uses MIT-pthreads.  *Note
  11780. MIT-pthreads::.
  11781.  
  11782. If you get the following error from `configure', it means that you have
  11783. something wrong with your compiler installation:
  11784.  
  11785.      checking for restartable system calls... configure: error can not
  11786.      run test programs while cross compiling
  11787.  
  11788. In this case, you should upgrade your compiler to a newer version.  You
  11789. may also be able to solve this problem by inserting the following row
  11790. into the `config.cache' file:
  11791.  
  11792.      ac_cv_sys_restartable_syscalls=${ac_cv_sys_restartable_syscalls='no'}
  11793.  
  11794. If you are using Solaris on a SPARC, the recommended compiler is `gcc'
  11795. 2.95.2 or 3.2. You can find this at `http://gcc.gnu.org/'.  Note that
  11796. `egcs' 1.1.1 and `gcc' 2.8.1 don't work reliably on SPARC!
  11797.  
  11798. The recommended `configure' line when using `gcc' 2.95.2 is:
  11799.  
  11800.      CC=gcc CFLAGS="-O3" \
  11801.      CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" \
  11802.      ./configure --prefix=/usr/local/mysql --with-low-memory \
  11803.          --enable-assembler
  11804.  
  11805. If you have an UltraSPARC system, you can get 4% better performance by
  11806. adding `-mcpu=v8 -Wa,-xarch=v8plusa' to the `CFLAGS' and `CXXFLAGS'
  11807. environment variables.
  11808.  
  11809. If you have Sun's Forte 5.0 (or newer) compiler, you can run
  11810. `configure' like this:
  11811.  
  11812.      CC=cc CFLAGS="-Xa -fast -native -xstrconst -mt" \
  11813.      CXX=CC CXXFLAGS="-noex -mt" \
  11814.      ./configure --prefix=/usr/local/mysql --enable-assembler
  11815.  
  11816. To create a 64-bit binary with Sun's Forte compiler, use the following
  11817. configuration options:
  11818.  
  11819.      CC=cc CFLAGS="-Xa -fast -native -xstrconst -mt -xarch=v9" \
  11820.      CXX=CC CXXFLAGS="-noex -mt -xarch=v9" ASFLAGS="-xarch=v9" \
  11821.      ./configure --prefix=/usr/local/mysql --enable-assembler
  11822.  
  11823. To create a 64-bit Solaris binary using `gcc', add `-m64' to `CFLAGS'
  11824. and `CXXFLAGS' and remove `--enable-assembler' from the `configure'
  11825. line. This works only with MySQL 4.0 and up; MySQL 3.23 does not
  11826. include the required modifications to support this.
  11827.  
  11828. In the MySQL benchmarks, we got a 4% speedup on an UltraSPARC when using
  11829. Forte 5.0 in 32-bit mode compared to using `gcc' 3.2 with the `-mcpu'
  11830. flag.
  11831.  
  11832. If you create a 64-bit `mysqld' binary, it is 4% slower than the 32-bit
  11833. binary, but can handle more threads and memory.
  11834.  
  11835. If you get a problem with `fdatasync' or `sched_yield', you can fix
  11836. this by adding `LIBS=-lrt' to the `configure' line
  11837.  
  11838. For compilers older than WorkShop 5.3, you might have to edit the
  11839. `configure' script. Change this line:
  11840.  
  11841.      #if !defined(__STDC__) || __STDC__ != 1
  11842.  
  11843. To this:
  11844.  
  11845.      #if !defined(__STDC__)
  11846.  
  11847. If you turn on `__STDC__' with the `-Xc' option, the Sun compiler can't
  11848. compile with the Solaris `pthread.h' header file.  This is a Sun bug
  11849. (broken compiler or broken include file).
  11850.  
  11851. If `mysqld' issues the following error message when you run it, you have
  11852. tried to compile MySQL with the Sun compiler without enabling the `-mt'
  11853. multi-thread option:
  11854.  
  11855.      libc internal error: _rmutex_unlock: rmutex not held
  11856.  
  11857. Add `-mt' to `CFLAGS' and `CXXFLAGS' and recompile.
  11858.  
  11859. If you are using the SFW version of `gcc' (which comes with Solaris 8),
  11860. you must add `/opt/sfw/lib' to the environment variable
  11861. `LD_LIBRARY_PATH' before running `configure'.
  11862.  
  11863. If you are using the `gcc' available from `sunfreeware.com', you may
  11864. have many problems.  To avoid this, you should recompile `gcc' and GNU
  11865. `binutils' on the machine where you will be running them.
  11866.  
  11867. If you get the following error when compiling MySQL with `gcc', it
  11868. means that your `gcc' is not configured for your version of Solaris:
  11869.  
  11870.      shell> gcc -O3 -g -O2 -DDBUG_OFF  -o thr_alarm ...
  11871.      ./thr_alarm.c: In function `signal_hand':
  11872.      ./thr_alarm.c:556: too many arguments to function `sigwait'
  11873.  
  11874. The proper thing to do in this case is to get the newest version of
  11875. `gcc' and compile it with your current `gcc' compiler.  At least for
  11876. Solaris 2.5, almost all binary versions of `gcc' have old, unusable
  11877. include files that will break all programs that use threads, and
  11878. possibly other programs!
  11879.  
  11880. Solaris doesn't provide static versions of all system libraries
  11881. (`libpthreads' and `libdl'), so you can't compile MySQL with
  11882. `--static'.  If you try to do so, you will get one of the following
  11883. errors:
  11884.  
  11885.      ld: fatal: library -ldl: not found
  11886.      undefined reference to `dlopen'
  11887.      cannot find -lrt
  11888.  
  11889. If you link your own MySQL client programs, you may see the following
  11890. error at runtime:
  11891.  
  11892.      ld.so.1: fatal: libmysqlclient.so.#:
  11893.      open failed: No such file or directory
  11894.  
  11895. This problem can be avoided by one of the following methods:
  11896.  
  11897.    * Link clients with the `-Wl,r/full/path/to/libmysqlclient.so' flag
  11898.      rather than with `-Lpath').
  11899.  
  11900.    * Copy `libmysqclient.so' to `/usr/lib'.
  11901.  
  11902.    * Add the pathname of the directory where `libmysqlclient.so' is
  11903.      located to the `LD_RUN_PATH' environment variable before running
  11904.      your client.
  11905.  
  11906. If you have problems with `configure' trying to link with `-lz' when
  11907. you don't have `zlib' installed, you have two options:
  11908.  
  11909.    * If you want to be able to use the compressed communication
  11910.      protocol, you need to get and install `zlib' from `ftp.gnu.org'.
  11911.  
  11912.    * Run `configure' with the `--with-named-z-libs=no' option when
  11913.      building MySQL.
  11914.  
  11915. If you are using `gcc' and have problems with loading user-defined
  11916. functions (UDFs) into MySQL, try adding `-lgcc' to the link line for
  11917. the UDF.
  11918.  
  11919. If you would like MySQL to start automatically, you can copy
  11920. `support-files/mysql.server' to `/etc/init.d' and create a symbolic
  11921. link to it named `/etc/rc3.d/S99mysql.server'.
  11922.  
  11923. If too many processes try to connect very rapidly to `mysqld', you will
  11924. see this error in the MySQL log:
  11925.  
  11926.      Error in accept: Protocol error
  11927.  
  11928. You might try starting the server with the `--back_log=50' option as a
  11929. workaround for this.  (Use `-O back_log=50' before MySQL 4.)
  11930.  
  11931. Solaris doesn't support core files for `setuid()' applications, so you
  11932. can't get a core file from `mysqld' if you are using the `--user'
  11933. option.
  11934.  
  11935. Solaris 2.7/2.8 Notes
  11936. .....................
  11937.  
  11938. Normally, you can use a Solaris 2.6 binary on Solaris 2.7 and 2.8.  Most
  11939. of the Solaris 2.6 issues also apply for Solaris 2.7 and 2.8.
  11940.  
  11941. MySQL 3.23.4 and above should be able to detect new versions of Solaris
  11942. automatically and enable workarounds for the following problems.
  11943.  
  11944. Solaris 2.7 / 2.8 has some bugs in the include files.  You may see the
  11945. following error when you use `gcc':
  11946.  
  11947.      /usr/include/widec.h:42: warning: `getwc' redefined
  11948.      /usr/include/wchar.h:326: warning: this is the location of the previous
  11949.      definition
  11950.  
  11951. If this occurs, you can fix the problem by copying
  11952. `/usr/include/widec.h' to `.../lib/gcc-lib/os/gcc-version/include' and
  11953. changing line 41 from this:
  11954.  
  11955.      #if     !defined(lint) && !defined(__lint)
  11956.  
  11957. To this:
  11958.  
  11959.      #if     !defined(lint) && !defined(__lint) && !defined(getwc)
  11960.  
  11961. Alternatively, you can edit `/usr/include/widec.h' directly.  Either
  11962. way, after you make the fix, you should remove `config.cache' and run
  11963. `configure' again.
  11964.  
  11965. If you get the following errors when you run `make', it's because
  11966. `configure' didn't detect the `curses.h' file (probably because of the
  11967. error in `/usr/include/widec.h'):
  11968.  
  11969.      In file included from mysql.cc:50:
  11970.      /usr/include/term.h:1060: syntax error before `,'
  11971.      /usr/include/term.h:1081: syntax error before `;'
  11972.  
  11973. The solution to this problem is to do one of the following:
  11974.  
  11975.    * Configure with `CFLAGS=-DHAVE_CURSES_H CXXFLAGS=-DHAVE_CURSES_H
  11976.      ./configure'.
  11977.  
  11978.    * Edit `/usr/include/widec.h' as indicated in the preceding
  11979.      discussion and re-run `configure'.
  11980.  
  11981.    * Remove the `#define HAVE_TERM' line from the `config.h' file and
  11982.      run `make' again.
  11983.  
  11984. If your linker can't find `-lz' when linking client programs, the
  11985. problem is probably that your `libz.so' file is installed in
  11986. `/usr/local/lib'.  You can fix this problem by one of the following
  11987. methods:
  11988.  
  11989.    * Add `/usr/local/lib' to `LD_LIBRARY_PATH'.
  11990.  
  11991.    * Add a link to `libz.so' from `/lib'.
  11992.  
  11993.    * If you are using Solaris 8, you can install the optional `zlib'
  11994.      from your Solaris 8 CD distribution.
  11995.  
  11996.    * Run `configure' with the `--with-named-z-libs=no' option when
  11997.      building MySQL.
  11998.  
  11999. Solaris x86 Notes
  12000. .................
  12001.  
  12002. On Solaris 8 on x86, `mysqld' will dump core if you remove the debug
  12003. symbols using `strip'.
  12004.  
  12005. If you are using `gcc' or `egcs' on Solaris x86 and you experience
  12006. problems with core dumps under load, you should use the following
  12007. `configure' command:
  12008.  
  12009.      CC=gcc CFLAGS="-O3 -fomit-frame-pointer -DHAVE_CURSES_H" \
  12010.      CXX=gcc \
  12011.      CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors \
  12012.          -fno-exceptions -fno-rtti -DHAVE_CURSES_H" \
  12013.      ./configure --prefix=/usr/local/mysql
  12014.  
  12015. This will avoid problems with the `libstdc++' library and with C++
  12016. exceptions.
  12017.  
  12018. If this doesn't help, you should compile a debug version and run it
  12019. with a trace file or under `gdb'.  *Note Using `gdb' on `mysqld': Using
  12020. gdb on mysqld.
  12021.  
  12022. BSD Notes
  12023. ---------
  12024.  
  12025. This section provides information about using MySQL on variants of BSD
  12026. Unix.
  12027.  
  12028. FreeBSD Notes
  12029. .............
  12030.  
  12031. FreeBSD 4.x or newer is recommended for running MySQL, because the
  12032. thread package is much more integrated.  To get a secure and stable
  12033. system, you should use only FreeBSD kernels that are marked `-RELEASE'.
  12034.  
  12035. The easiest (and preferred) way to install MySQL is to use the
  12036. `mysql-server' and `mysql-client' ports available at
  12037. `http://www.freebsd.org/'.  Using these ports gives you the following
  12038. benefits:
  12039.  
  12040.    * A working MySQL with all optimizations enabled that are known to
  12041.      work on your version of FreeBSD.
  12042.  
  12043.    * Automatic configuration and build.
  12044.  
  12045.    * Startup scripts installed in `/usr/local/etc/rc.d'.
  12046.  
  12047.    * The ability to use `pkg_info -L' to see which files are installed.
  12048.  
  12049.    * The ability to use `pkg_delete' to remove MySQL if you no longer
  12050.      want it on your machine.
  12051.  
  12052. It is recommended you use MIT-pthreads on FreeBSD 2.x, and native
  12053. threads on Versions 3 and up. It is possible to run with native threads
  12054. on some late 2.2.x versions, but you may encounter problems shutting
  12055. down `mysqld'.
  12056.  
  12057. Unfortunately, certain function calls on FreeBSD are not yet fully
  12058. thread-safe.  Most notably, this includes the `gethostbyname()'
  12059. function, which is used by MySQL to convert hostnames into IP
  12060. addresses. Under certain circumstances, the `mysqld' process will
  12061. suddenly cause 100% CPU load and will be unresponsive. If you encounter
  12062. this problem, try to start MySQL using the `--skip-name-resolve' option.
  12063.  
  12064. Alternatively, you can link MySQL on FreeBSD 4.x against the
  12065. LinuxThreads library, which avoids a few of the problems that the
  12066. native FreeBSD thread implementation has. For a very good comparison of
  12067. LinuxThreads versus native threads, see Jeremy Zawodny's article
  12068. `FreeBSD or Linux for your MySQL Server?' at
  12069. `http://jeremy.zawodny.com/blog/archives/000697.html'.
  12070.  
  12071. A known problem when using LinuxThreads on FreeBSD is that the
  12072. `wait_timeout' value is not honored (probably a signal handling problem
  12073. in FreeBSD/LinuxThreads).  This is supposed to be fixed in FreeBSD 5.0.
  12074. The symptom is that persistent connections can hang for a very long
  12075. time without getting closed down.
  12076.  
  12077. The MySQL build process requires GNU make (`gmake') to work.  If GNU
  12078. `make' is not available, you must install it first before compiling
  12079. MySQL.
  12080.  
  12081. The recommended way to compile and install MySQL on FreeBSD with `gcc'
  12082. (2.95.2 and up) is:
  12083.  
  12084.      CC=gcc CFLAGS="-O2 -fno-strength-reduce" \
  12085.          CXX=gcc CXXFLAGS="-O2 -fno-rtti -fno-exceptions \
  12086.          -felide-constructors -fno-strength-reduce" \
  12087.          ./configure --prefix=/usr/local/mysql --enable-assembler
  12088.      gmake
  12089.      gmake install
  12090.      cd /usr/local/mysql
  12091.      bin/mysql_install_db --user=mysql
  12092.      bin/mysqld_safe &
  12093.  
  12094. If you notice that `configure' will use MIT-pthreads, you should read
  12095. the MIT-pthreads notes.  *Note MIT-pthreads::.
  12096.  
  12097. If you get an error from `make install' that it can't find
  12098. `/usr/include/pthreads', `configure' didn't detect that you need
  12099. MIT-pthreads. To fix this problem, remove `config.cache', then re-run
  12100. `configure' with the `--with-mit-threads' option.
  12101.  
  12102. Be sure that your name resolver setup is correct.  Otherwise, you may
  12103. experience resolver delays or failures when connecting to `mysqld'.
  12104. Also make sure that the `localhost' entry in the `/etc/hosts' file is
  12105. correct.  The file should start with a line similar to this:
  12106.  
  12107.      127.0.0.1       localhost localhost.your.domain
  12108.  
  12109. FreeBSD is known to have a very low default file handle limit.  *Note
  12110. Not enough file handles::.  Start the server by using the
  12111. `--open-files-limit' option for `mysqld_safe', or raise the limits for
  12112. the `mysqld' user in `/etc/login.conf' and rebuild it with `cap_mkdb
  12113. /etc/login.conf'.  Also be sure that you set the appropriate class for
  12114. this user in the password file if you are not using the default (use
  12115. `chpass mysqld-user-name').  *Note `mysqld_safe': mysqld_safe.
  12116.  
  12117. If you have a lot of memory, you should consider rebuilding the kernel
  12118. to allow MySQL to use more than 512MB of RAM.  Take a look at `option
  12119. MAXDSIZ' in the LINT config file for more information.
  12120.  
  12121. If you get problems with the current date in MySQL, setting the `TZ'
  12122. variable will probably help.  *Note Environment variables::.
  12123.  
  12124. NetBSD Notes
  12125. ............
  12126.  
  12127. To compile on NetBSD, you need GNU `make'. Otherwise, the build process
  12128. will fail when `make' tries to run `lint' on C++ files.
  12129.  
  12130. OpenBSD 2.5 Notes
  12131. .................
  12132.  
  12133. On OpenBSD Version 2.5, you can compile MySQL with native threads with
  12134. the following options:
  12135.  
  12136.      CFLAGS=-pthread CXXFLAGS=-pthread ./configure --with-mit-threads=no
  12137.  
  12138. OpenBSD 2.8 Notes
  12139. .................
  12140.  
  12141. Our users have reported that OpenBSD 2.8 has a threading bug that causes
  12142. problems with MySQL.  The OpenBSD Developers have fixed the problem,
  12143. but as of January 25, 2001, it's only available in the "-current"
  12144. branch.  The symptoms of this threading bug are slow response, high
  12145. load, high CPU usage, and crashes.
  12146.  
  12147. If you get an error like `Error in accept:: Bad file descriptor' or
  12148. error 9 when trying to open tables or directories, the problem is
  12149. probably that you have not allocated enough file descriptors for MySQL.
  12150.  
  12151. In this case, try starting `mysqld_safe' as `root' with the following
  12152. options:
  12153.  
  12154.      mysqld_safe --user=mysql --open-files-limit=2048 &
  12155.  
  12156. BSD/OS Version 2.x Notes
  12157. ........................
  12158.  
  12159. If you get the following error when compiling MySQL, your `ulimit'
  12160. value for virtual memory is too low:
  12161.  
  12162.      item_func.h: In method
  12163.      `Item_func_ge::Item_func_ge(const Item_func_ge &)':
  12164.      item_func.h:28: virtual memory exhausted
  12165.      make[2]: *** [item_func.o] Error 1
  12166.  
  12167. Try using `ulimit -v 80000' and run `make' again.  If this doesn't work
  12168. and you are using `bash', try switching to `csh' or `sh'; some BSDI
  12169. users have reported problems with `bash' and `ulimit'.
  12170.  
  12171. If you are using `gcc', you may also use have to use the
  12172. `--with-low-memory' flag for `configure' to be able to compile
  12173. `sql_yacc.cc'.
  12174.  
  12175. If you get problems with the current date in MySQL, setting the `TZ'
  12176. variable will probably help.  *Note Environment variables::.
  12177.  
  12178. BSD/OS Version 3.x Notes
  12179. ........................
  12180.  
  12181. Upgrade to BSD/OS Version 3.1.  If that is not possible, install
  12182. BSDIpatch M300-038.
  12183.  
  12184. Use the following command when configuring MySQL:
  12185.  
  12186.      env CXX=shlicc++ CC=shlicc2 \
  12187.      ./configure \
  12188.          --prefix=/usr/local/mysql \
  12189.          --localstatedir=/var/mysql \
  12190.          --without-perl \
  12191.          --with-unix-socket-path=/var/mysql/mysql.sock
  12192.  
  12193. The following is also known to work:
  12194.  
  12195.      env CC=gcc CXX=gcc CXXFLAGS=-O3 \
  12196.      ./configure \
  12197.          --prefix=/usr/local/mysql \
  12198.          --with-unix-socket-path=/var/mysql/mysql.sock
  12199.  
  12200. You can change the directory locations if you wish, or just use the
  12201. defaults by not specifying any locations.
  12202.  
  12203. If you have problems with performance under heavy load, try using the
  12204. `--skip-thread-priority' option to `mysqld'!  This will run all threads
  12205. with the same priority. On BSDI Version 3.1, this gives better
  12206. performance, at least until BSDI fixes its thread scheduler.
  12207.  
  12208. If you get the error `virtual memory exhausted' while compiling, you
  12209. should try using `ulimit -v 80000' and running `make' again.  If this
  12210. doesn't work and you are using `bash', try switching to `csh' or `sh';
  12211. some BSDI users have reported problems with `bash' and `ulimit'.
  12212.  
  12213. BSD/OS Version 4.x Notes
  12214. ........................
  12215.  
  12216. BSDI Version 4.x has some thread-related bugs.  If you want to use
  12217. MySQL on this, you should install all thread-related patches.  At least
  12218. M400-023 should be installed.
  12219.  
  12220. On some BSDI Version 4.x systems, you may get problems with shared
  12221. libraries.  The symptom is that you can't execute any client programs,
  12222. for example, `mysqladmin'.  In this case, you need to reconfigure not
  12223. to use shared libraries with the `--disable-shared' option to configure.
  12224.  
  12225. Some customers have had problems on BSDI 4.0.1 that the `mysqld' binary
  12226. after a while can't open tables.  This is because some
  12227. library/system-related bug causes `mysqld' to change current directory
  12228. without having asked for that to happen.
  12229.  
  12230. The fix is to either upgrade MySQL to at least version 3.23.34 or, after
  12231. running `configure', remove the line `#define HAVE_REALPATH' from
  12232. `config.h' before running `make'.
  12233.  
  12234. Note that this means that you can't symbolically link a database
  12235. directories to another database directory or symbolic link a table to
  12236. another database on BSDI.  (Making a symbolic link to another disk is
  12237. okay).
  12238.  
  12239. Other Unix Notes
  12240. ----------------
  12241.  
  12242. HP-UX Version 10.20 Notes
  12243. .........................
  12244.  
  12245. There are a couple of small problems when compiling MySQL on HP-UX.  We
  12246. recommend that you use `gcc' instead of the HP-UX native compiler,
  12247. because `gcc' produces better code.
  12248.  
  12249. We recommend using `gcc' 2.95 on HP-UX.  Don't use high optimization
  12250. flags (such as `-O6') because they may not be safe on HP-UX.
  12251.  
  12252. The following `configure' line should work with `gcc' 2.95:
  12253.  
  12254.      CFLAGS="-I/opt/dce/include -fpic" \
  12255.      CXXFLAGS="-I/opt/dce/include -felide-constructors -fno-exceptions \
  12256.      -fno-rtti" \
  12257.      CXX=gcc \
  12258.      ./configure --with-pthread \
  12259.          --with-named-thread-libs='-ldce' \
  12260.          --prefix=/usr/local/mysql --disable-shared
  12261.  
  12262. The following `configure' line should work with `gcc' 3.1:
  12263.  
  12264.      CFLAGS="-DHPUX -I/opt/dce/include -O3 -fPIC" CXX=gcc \
  12265.      CXXFLAGS="-DHPUX -I/opt/dce/include -felide-constructors \
  12266.          -fno-exceptions -fno-rtti -O3 -fPIC" \
  12267.      ./configure --prefix=/usr/local/mysql \
  12268.          --with-extra-charsets=complex --enable-thread-safe-client \
  12269.          --enable-local-infile  --with-pthread \
  12270.          --with-named-thread-libs=-ldce --with-lib-ccflags=-fPIC
  12271.          --disable-shared
  12272.  
  12273. HP-UX Version 11.x Notes
  12274. ........................
  12275.  
  12276. For HP-UX Version 11.x, we recommend MySQL 3.23.15 or later.
  12277.  
  12278. Because of some critical bugs in the standard HP-UX libraries, you
  12279. should install the following patches before trying to run MySQL on
  12280. HP-UX 11.0:
  12281.  
  12282.      PHKL_22840 Streams cumulative
  12283.      PHNE_22397 ARPA cumulative
  12284.  
  12285. This will solve the problem of getting `EWOULDBLOCK' from `recv()' and
  12286. `EBADF' from `accept()' in threaded applications.
  12287.  
  12288. If you are using `gcc' 2.95.1 on an unpatched HP-UX 11.x system, you
  12289. will get the error:
  12290.  
  12291.      In file included from /usr/include/unistd.h:11,
  12292.                       from ../include/global.h:125,
  12293.                       from mysql_priv.h:15,
  12294.                       from item.cc:19:
  12295.      /usr/include/sys/unistd.h:184: declaration of C function ...
  12296.      /usr/include/sys/pthread.h:440: previous declaration ...
  12297.      In file included from item.h:306,
  12298.                       from mysql_priv.h:158,
  12299.                       from item.cc:19:
  12300.  
  12301. The problem is that HP-UX doesn't define `pthreads_atfork()'
  12302. consistently.  It has conflicting prototypes in
  12303. `/usr/include/sys/unistd.h':184 and `/usr/include/sys/pthread.h':440.
  12304.  
  12305. One solution is to copy `/usr/include/sys/unistd.h' into
  12306. `mysql/include' and edit `unistd.h' and change it to match the
  12307. definition in `pthread.h'.  Look for this line:
  12308.  
  12309.      extern int pthread_atfork(void (*prepare)(), void (*parent)(),
  12310.                                                void (*child)());
  12311.  
  12312. Change it to look like this:
  12313.  
  12314.      extern int pthread_atfork(void (*prepare)(void), void (*parent)(void),
  12315.                                                void (*child)(void));
  12316.  
  12317. After making the change, the following `configure' line should work:
  12318.  
  12319.      CFLAGS="-fomit-frame-pointer -O3 -fpic" CXX=gcc \
  12320.      CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -O3" \
  12321.      ./configure --prefix=/usr/local/mysql --disable-shared
  12322.  
  12323. If you are using MySQL 4.0.5 with the HP-UX compiler, you can use the
  12324. following command (which has been tested with `cc' B.11.11.04):
  12325.  
  12326.      CC=cc CXX=aCC CFLAGS=+DD64 CXXFLAGS=+DD64 ./configure \
  12327.          --with-extra-character-set=complex
  12328.  
  12329. You can ignore any errors of the following type:
  12330.  
  12331.      aCC: warning 901: unknown option: `-3': use +help for online
  12332.      documentation
  12333.  
  12334. If you get the following error from `configure', verify that you don't
  12335. have the path to the K&R compiler before the path to the HP-UX C and
  12336. C++ compiler:
  12337.  
  12338.      checking for cc option to accept ANSI C... no
  12339.      configure: error: MySQL requires an ANSI C compiler (and a C++ compiler).
  12340.      Try gcc. See the Installation chapter in the Reference Manual.
  12341.  
  12342. Another reason for not being able to compile is that you didn't define
  12343. the `+DD64' flags as just described.
  12344.  
  12345. Another possibility for HP-UX 11 is to use MySQL binaries for HP-UX
  12346. 10.20.  We have received reports from some users that these binaries
  12347. work fine on HP-UX 11.00. If you encounter problems, be sure to check
  12348. your HP-UX patch level.
  12349.  
  12350. IBM-AIX notes
  12351. .............
  12352.  
  12353. Automatic detection of `xlC' is missing from Autoconf, so a number of
  12354. variables need to be set before running `configure'. The following
  12355. example uses the IBM compiler:
  12356.  
  12357.      export CC="xlc_r -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192 "
  12358.      export CXX="xlC_r -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192"
  12359.      export CFLAGS="-I /usr/local/include"
  12360.      export LDFLAGS="-L /usr/local/lib"
  12361.      export CPPFLAGS=$CFLAGS
  12362.      export CXXFLAGS=$CFLAGS
  12363.      
  12364.      ./configure --prefix=/usr/local \
  12365.                      --localstatedir=/var/mysql \
  12366.                      --sbindir='/usr/local/bin' \
  12367.                      --libexecdir='/usr/local/bin' \
  12368.                      --enable-thread-safe-client \
  12369.                      --enable-large-files
  12370.  
  12371. The preceding options are used to compile the MySQL distribution that
  12372. can be found at `http://www-frec.bull.com/'.
  12373.  
  12374. If you change the `-O3' to `-O2' in the preceding `configure' line, you
  12375. must also remove the `-qstrict' option. This is a limitation in the IBM
  12376. C compiler.
  12377.  
  12378. If you are using `gcc' or `egcs' to compile MySQL, you _must_ use the
  12379. `-fno-exceptions' flag, because the exception handling in `gcc'/`egcs'
  12380. is not thread-safe!  (This is tested with `egcs' 1.1.)  There are also
  12381. some known problems with IBM's assembler that may cause it to generate
  12382. bad code when used with `gcc'.
  12383.  
  12384. We recommend the following `configure' line with `egcs' and `gcc' 2.95
  12385. on AIX:
  12386.  
  12387.      CC="gcc -pipe -mcpu=power -Wa,-many" \
  12388.      CXX="gcc -pipe -mcpu=power -Wa,-many" \
  12389.      CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti" \
  12390.      ./configure --prefix=/usr/local/mysql --with-low-memory
  12391.  
  12392. The `-Wa,-many' option is necessary for the compile to be successful.
  12393. IBM is aware of this problem but is in no hurry to fix it because of the
  12394. workaround that is available.  We don't know if the `-fno-exceptions'
  12395. is required with `gcc' 2.95, but because MySQL doesn't use exceptions
  12396. and the option generates faster code, we recommend that you should
  12397. always use it with `egcs' / `gcc'.
  12398.  
  12399. If you get a problem with assembler code, try changing the `-mcpu=XXX'
  12400. option to match your CPU. Typically `power2', `power', or `powerpc' may
  12401. need to be used.  Alternatively, you might need to use `604' or `604e'.
  12402. We are not positive but suspect that `power' would likely be safe most
  12403. of the time, even on a power2 machine.
  12404.  
  12405. If you don't know what your CPU is, execute a `uname -m' command.  It
  12406. will produce a string that looks like `000514676700', with a format of
  12407. `xxyyyyyymmss' where `xx' and `ss' are always `00', `yyyyyy' is a
  12408. unique system ID and `mm' is the ID of the CPU Planar.  A chart of
  12409. these values can be found at
  12410. `http://publib.boulder.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/uname.htm'.
  12411. This will give you a machine type and a machine model you can use to
  12412. determine what type of CPU you have.
  12413.  
  12414. If you have problems with signals (MySQL dies unexpectedly under high
  12415. load), you may have found an OS bug with threads and signals.  In this
  12416. case, you can tell MySQL not to use signals by configuring as follows:
  12417.  
  12418.      CFLAGS=-DDONT_USE_THR_ALARM CXX=gcc \
  12419.      CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti \
  12420.      -DDONT_USE_THR_ALARM" \
  12421.      ./configure --prefix=/usr/local/mysql --with-debug \
  12422.          --with-low-memory
  12423.  
  12424. This doesn't affect the performance of MySQL, but has the side effect
  12425. that you can't kill clients that are "sleeping" on a connection with
  12426. `mysqladmin kill' or `mysqladmin shutdown'.  Instead, the client will
  12427. die when it issues its next command.
  12428.  
  12429. On some versions of AIX, linking with `libbind.a' makes
  12430. `getservbyname()' dump core.  This is an AIX bug and should be reported
  12431. to IBM.
  12432.  
  12433. For AIX 4.2.1 and `gcc', you have to make the following changes.
  12434.  
  12435. After configuring, edit `config.h' and `include/my_config.h' and change
  12436. the line that says this:
  12437.  
  12438.      #define HAVE_SNPRINTF 1
  12439.  
  12440. to this:
  12441.  
  12442.      #undef HAVE_SNPRINTF
  12443.  
  12444. And finally, in `mysqld.cc', you need to add a prototype for
  12445. `initgroups()'.
  12446.  
  12447.      #ifdef _AIX41
  12448.      extern "C" int initgroups(const char *,int);
  12449.      #endif
  12450.  
  12451. If you need to allocate a lot of memory to the `mysqld' process, it's
  12452. not enough to just use `ulimit -d unlimited'. You may also have to
  12453. modify `mysqld_safe' to add a line something like this:
  12454.  
  12455.      export LDR_CNTRL='MAXDATA=0x80000000'
  12456.  
  12457. You can find more information about using a lot of memory at
  12458. `http://publib16.boulder.ibm.com/pseries/en_US/aixprggd/genprogc/lrg_prg_support.htm'.
  12459.  
  12460. SunOS 4 Notes
  12461. .............
  12462.  
  12463. On SunOS 4, MIT-pthreads is needed to compile MySQL. This in turn means
  12464. you will need GNU `make'.
  12465.  
  12466. Some SunOS 4 systems have problems with dynamic libraries and `libtool'.
  12467. You can use the following `configure' line to avoid this problem:
  12468.  
  12469.      ./configure --disable-shared --with-mysqld-ldflags=-all-static
  12470.  
  12471. When compiling `readline', you may get warnings about duplicate defines.
  12472. These can be ignored.
  12473.  
  12474. When compiling `mysqld', there will be some `implicit declaration of
  12475. function' warnings. These can be ignored.
  12476.  
  12477. Alpha-DEC-UNIX Notes (Tru64)
  12478. ............................
  12479.  
  12480. If you are using `egcs' 1.1.2 on Digital Unix, you should upgrade to
  12481. `gcc' 2.95.2, because `egcs' on DEC has some serious bugs!
  12482.  
  12483. When compiling threaded programs under Digital Unix, the documentation
  12484. recommends using the `-pthread' option for `cc' and `cxx' and the
  12485. `-lmach -lexc' libraries (in addition to `-lpthread').  You should run
  12486. `configure' something like this:
  12487.  
  12488.      CC="cc -pthread" CXX="cxx -pthread -O" \
  12489.      ./configure --with-named-thread-libs="-lpthread -lmach -lexc -lc"
  12490.  
  12491. When compiling `mysqld', you may see a couple of warnings like this:
  12492.  
  12493.      mysqld.cc: In function void handle_connections()':
  12494.      mysqld.cc:626: passing long unsigned int *' as argument 3 of
  12495.      accept(int,sockadddr *, int *)'
  12496.  
  12497. You can safely ignore these warnings.  They occur because `configure'
  12498. can detect only errors, not warnings.
  12499.  
  12500. If you start the server directly from the command line, you may have
  12501. problems with it dying when you log out.  (When you log out, your
  12502. outstanding processes receive a `SIGHUP' signal.)  If so, try starting
  12503. the server like this:
  12504.  
  12505.      nohup mysqld [OPTIONS] &
  12506.  
  12507. `nohup' causes the command following it to ignore any `SIGHUP' signal
  12508. sent from the terminal.  Alternatively, start the server by running
  12509. `mysqld_safe', which invokes `mysqld' using `nohup' for you.  *Note
  12510. `mysqld_safe': mysqld_safe.
  12511.  
  12512. If you get a problem when compiling `mysys/get_opt.c', just remove the
  12513. `#define _NO_PROTO' line from the start of that file.
  12514.  
  12515. If you are using Compaq's CC compiler, the following `configure' line
  12516. should work:
  12517.  
  12518.      CC="cc -pthread"
  12519.      CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
  12520.      CXX="cxx -pthread"
  12521.      CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all \
  12522.          -arch host -noexceptions -nortti"
  12523.      export CC CFLAGS CXX CXXFLAGS
  12524.      ./configure \
  12525.          --prefix=/usr/local/mysql \
  12526.          --with-low-memory \
  12527.          --enable-large-files \
  12528.          --enable-shared=yes \
  12529.          --with-named-thread-libs="-lpthread -lmach -lexc -lc"
  12530.      gnumake
  12531.  
  12532. If you get a problem with `libtool' when compiling with shared libraries
  12533. as just shown, when linking `mysql', you should be able to get around
  12534. this by issuing these commands:
  12535.  
  12536.      cd mysql
  12537.      /bin/sh ../libtool --mode=link cxx -pthread  -O3 -DDBUG_OFF \
  12538.          -O4 -ansi_alias -ansi_args -fast -inline speed \
  12539.          -speculate all \ -arch host  -DUNDEF_HAVE_GETHOSTBYNAME_R \
  12540.          -o mysql  mysql.o readline.o sql_string.o completion_hash.o \
  12541.          ../readline/libreadline.a -lcurses \
  12542.          ../libmysql/.libs/libmysqlclient.so  -lm
  12543.      cd ..
  12544.      gnumake
  12545.      gnumake install
  12546.      scripts/mysql_install_db
  12547.  
  12548. Alpha-DEC-OSF/1 Notes
  12549. .....................
  12550.  
  12551. If you have problems compiling and have DEC `CC' and `gcc' installed,
  12552. try running `configure' like this:
  12553.  
  12554.      CC=cc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 \
  12555.      ./configure --prefix=/usr/local/mysql
  12556.  
  12557. If you get problems with the `c_asm.h' file, you can create and use a
  12558. 'dummy' `c_asm.h' file with:
  12559.  
  12560.      touch include/c_asm.h
  12561.      CC=gcc CFLAGS=-I./include \
  12562.      CXX=gcc CXXFLAGS=-O3 \
  12563.      ./configure --prefix=/usr/local/mysql
  12564.  
  12565. Note that the following problems with the `ld' program can be fixed by
  12566. downloading the latest DEC (Compaq) patch kit from:
  12567. `http://ftp.support.compaq.com/public/unix/'.
  12568.  
  12569. On OSF/1 V4.0D and compiler "DEC C V5.6-071 on Digital Unix V4.0 (Rev.
  12570. 878)," the compiler had some strange behavior (undefined `asm' symbols).
  12571. `/bin/ld' also appears to be broken (problems with `_exit undefined'
  12572. errors occurring while linking `mysqld').  On this system, we have
  12573. managed to compile MySQL with the following `configure' line, after
  12574. replacing `/bin/ld' with the version from OSF 4.0C:
  12575.  
  12576.      CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  12577.  
  12578. With the Digital compiler "C++ V6.1-029," the following should work:
  12579.  
  12580.      CC=cc -pthread
  12581.      CFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed \
  12582.             -speculate all -arch host
  12583.      CXX=cxx -pthread
  12584.      CXXFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed \
  12585.               -speculate all -arch host -noexceptions -nortti
  12586.      export CC CFLAGS CXX CXXFLAGS
  12587.      ./configure --prefix=/usr/mysql/mysql \
  12588.                  --with-mysqld-ldflags=-all-static --disable-shared \
  12589.                  --with-named-thread-libs="-lmach -lexc -lc"
  12590.  
  12591. In some versions of OSF/1, the `alloca()' function is broken. Fix this
  12592. by removing the line in `config.h' that defines `'HAVE_ALLOCA''.
  12593.  
  12594. The `alloca()' function also may have an incorrect prototype in
  12595. `/usr/include/alloca.h'.  This warning resulting from this can be
  12596. ignored.
  12597.  
  12598. `configure' will use the following thread libraries automatically:
  12599. `--with-named-thread-libs="-lpthread -lmach -lexc -lc"'.
  12600.  
  12601. When using `gcc', you can also try running `configure' like this:
  12602.  
  12603.      CFLAGS=-D_PTHREAD_USE_D4 CXX=gcc CXXFLAGS=-O3 ./configure ...
  12604.  
  12605. If you have problems with signals (MySQL dies unexpectedly under high
  12606. load), you may have found an OS bug with threads and signals. In this
  12607. case, you can tell MySQL not to use signals by configuring with:
  12608.  
  12609.      CFLAGS=-DDONT_USE_THR_ALARM \
  12610.      CXXFLAGS=-DDONT_USE_THR_ALARM \
  12611.      ./configure ...
  12612.  
  12613. This doesn't affect the performance of MySQL, but has the side effect
  12614. that you can't kill clients that are "sleeping" on a connection with
  12615. `mysqladmin kill' or `mysqladmin shutdown'.  Instead, the client will
  12616. die when it issues its next command.
  12617.  
  12618. With `gcc' 2.95.2, you will probably run into the following compile
  12619. error:
  12620.  
  12621.      sql_acl.cc:1456: Internal compiler error in `scan_region',
  12622.      at except.c:2566
  12623.      Please submit a full bug report.
  12624.  
  12625. To fix this, you should change to the `sql' directory and do a
  12626. cut-and-paste of the last `gcc' line, but change `-O3' to `-O0' (or add
  12627. `-O0' immediately after `gcc' if you don't have any `-O' option on your
  12628. compile line).  After this is done, you can just change back to the
  12629. top-level directory and run `make' again.
  12630.  
  12631. SGI Irix Notes
  12632. ..............
  12633.  
  12634. If you are using Irix Version 6.5.3 or newer, `mysqld' will be able to
  12635. create threads only if you run it as a user that has `CAP_SCHED_MGT'
  12636. privileges (such as `root') or give the `mysqld' server this privilege
  12637. with the following shell command:
  12638.  
  12639.      chcap "CAP_SCHED_MGT+epi" /opt/mysql/libexec/mysqld
  12640.  
  12641. You may have to undefine some symbols in `config.h' after running
  12642. `configure' and before compiling.
  12643.  
  12644. In some Irix implementations, the `alloca()' function is broken.  If the
  12645. `mysqld' server dies on some `SELECT' statements, remove the lines from
  12646. `config.h' that define `HAVE_ALLOC' and `HAVE_ALLOCA_H'.  If
  12647. `mysqladmin create' doesn't work, remove the line from `config.h' that
  12648. defines `HAVE_READDIR_R'.  You may have to remove the `HAVE_TERM_H'
  12649. line as well.
  12650.  
  12651. SGI recommends that you install all the patches on this page as a set:
  12652. `http://support.sgi.com/surfzone/patches/patchset/6.2_indigo.rps.html'
  12653.  
  12654. At the very minimum, you should install the latest kernel rollup, the
  12655. latest `rld' rollup, and the latest `libc' rollup.
  12656.  
  12657. You definitely need all the POSIX patches on this page, for pthreads
  12658. support:
  12659.  
  12660. `http://support.sgi.com/surfzone/patches/patchset/6.2_posix.rps.html'
  12661.  
  12662. If you get the something like the following error when compiling
  12663. `mysql.cc':
  12664.  
  12665.      "/usr/include/curses.h", line 82: error(1084):
  12666.      invalid combination of type
  12667.  
  12668. Type the following in the top-level directory of your MySQL source tree:
  12669.  
  12670.      extra/replace bool curses_bool < /usr/include/curses.h > include/curses.h
  12671.      make
  12672.  
  12673. There have also been reports of scheduling problems.  If only one
  12674. thread is running, performance is slow.  Avoid this by starting another
  12675. client.  This may lead to a two-to-tenfold increase in execution speed
  12676. thereafter for the other thread.  This is a poorly understood problem
  12677. with Irix threads; you may have to improvise to find solutions until
  12678. this can be fixed.
  12679.  
  12680. If you are compiling with `gcc', you can use the following `configure'
  12681. command:
  12682.  
  12683.      CC=gcc CXX=gcc CXXFLAGS=-O3 \
  12684.      ./configure --prefix=/usr/local/mysql --enable-thread-safe-client \
  12685.          --with-named-thread-libs=-lpthread
  12686.  
  12687. On Irix 6.5.11 with native Irix C and C++ compilers ver. 7.3.1.2, the
  12688. following is reported to work
  12689.  
  12690.      CC=cc CXX=CC CFLAGS='-O3 -n32 -TARG:platform=IP22 -I/usr/local/include \
  12691.      -L/usr/local/lib' CXXFLAGS='-O3 -n32 -TARG:platform=IP22 \
  12692.      -I/usr/local/include -L/usr/local/lib' \
  12693.      ./configure --prefix=/usr/local/mysql --with-innodb --with-berkeley-db \
  12694.          --with-libwrap=/usr/local \
  12695.          --with-named-curses-libs=/usr/local/lib/libncurses.a
  12696.  
  12697. SCO Notes
  12698. .........
  12699.  
  12700. The current port is tested only on "sco3.2v5.0.5," "sco3.2v5.0.6," and
  12701. "sco3.2v5.0.7" systems. There has also been a lot of progress on a port
  12702. to "sco 3.2v4.2."  Open Server 5.0.8(Legend) will have native threads
  12703. and allow files greater than 2GB.  The current maximum file size is 2GB.
  12704.  
  12705. We have been able to compile MySQL with the following `configure'
  12706. command on on OpenServer with `gcc' 2.95.3.
  12707.  
  12708.      CC=gcc CXX=gcc ./configure --prefix=/usr/local/mysql \
  12709.          --enable-thread-safe-client --with-innodb \
  12710.          --with-openssl --with-vio --with-extra-charsets=complex
  12711.  
  12712. `gcc' is available at
  12713. `ftp://ftp.sco.com/pub/openserver5/opensrc/gnutools-5.0.7Kj'.
  12714.  
  12715. This development system requires the OpenServer Execution Enviroment
  12716. Supplement oss646B on OpenServer 5.0.6 and oss656B and The OpenSource
  12717. libraries found in gwxlibs.  All OpenSource tools are in the `opensrc'
  12718. directory.  They are available at
  12719. `ftp://ftp.sco.com/pub/openserver5/opensrc/'.
  12720.  
  12721. We recommend using the latest production release of MySQL.  Currently
  12722. MySQL-4.0.x is the latest production release.  There were some problems
  12723. with MySQL 4.0.17 and MySQL 4.0.18, but they have now been fixed.
  12724.  
  12725. SCO provides operating system patches at
  12726. `ftp://ftp.sco.com/pub/openserver5' for OpenServer 5.0.[0-6] and
  12727. `ftp://ftp.sco.com/pub/openserverv5/507' for OpenServer 5.0.7.
  12728.  
  12729. SCO provides information about security fixes at
  12730. `ftp://ftp.sco.com/pub/security/OpenServer' for OpenServer 5.0.x.
  12731.  
  12732. The maximum file size on an OpenSever 5.0.x system is 2GB.
  12733.  
  12734. The total memory which could be allocated for streams buffers, clists
  12735. and lock records cannot exceed 60MB on OpenServer 5.0.x.
  12736.  
  12737. Streams buffers are allocated in units of 4096 byte pages, clists are 70
  12738. bytes each, and lock records are 64 bytes each, so:
  12739.  
  12740.      (NSTRPAGES * 4096) + (NCLIST * 70) + (MAX_FLCKREC * 64) <= 62914560
  12741.  
  12742. Follow this procedure to configure the Database Services option. If you
  12743. are unsure whether an application requires this, see the documentation
  12744. provided with the application.
  12745.  
  12746.   1. Log in as `root'.
  12747.  
  12748.   2. Enable the SUDS driver by editing the `/etc/conf/sdevice.d/suds'
  12749.      file.  Change the `N' in the second field to a `Y'.
  12750.  
  12751.   3. Use `mkdev aio' or the Hardware/Kernel Manager to enable support
  12752.      for asynchronous I/O and relink the kernel. To allow users to lock
  12753.      down memory for use with this type of I/O, update the
  12754.      aiomemlock(F) file. This file should be updated to include the
  12755.      names of users that can use AIO and the maximum amounts of memory
  12756.      they can lock down.
  12757.  
  12758.   4. Many applications use setuid binaries so that you need to specify
  12759.      only a single user. See the documentation provided with the
  12760.      application to see if this is the case for your application.
  12761.  
  12762. After you complete this process, reboot the system to create a new
  12763. kernel incorporating these changes.
  12764.  
  12765. By default, the entries in `/etc/conf/cf.d/mtune' are set as follows:
  12766.  
  12767.      Value           Default         Min             Max
  12768.      -----           -------         ---             ---
  12769.      NBUF            0               24              450000
  12770.      NHBUF           0               32              524288
  12771.      NMPBUF          0               12              512
  12772.      MAX_INODE       0               100             64000
  12773.      MAX_FILE        0               100             64000
  12774.      CTBUFSIZE       128             0               256
  12775.      MAX_PROC        0               50              16000
  12776.      MAX_REGION      0               500             160000
  12777.      NCLIST          170             120             16640
  12778.      MAXUP           100             15              16000
  12779.      NOFILES         110             60              11000
  12780.      NHINODE         128             64              8192
  12781.      NAUTOUP         10              0               60
  12782.      NGROUPS         8               0               128
  12783.      BDFLUSHR        30              1               300
  12784.      MAX_FLCKREC     0               50              16000
  12785.      PUTBUFSZ        8000            2000            20000
  12786.      MAXSLICE        100             25              100
  12787.      ULIMIT          4194303         2048            4194303
  12788.      * Streams Parameters
  12789.      NSTREAM         64              1               32768
  12790.      NSTRPUSH        9               9               9
  12791.      NMUXLINK        192             1               4096
  12792.      STRMSGSZ        16384           4096            524288
  12793.      STRCTLSZ        1024            1024            1024
  12794.      STRMAXBLK       524288          4096            524288
  12795.      NSTRPAGES       500             0               8000
  12796.      STRSPLITFRAC    80              50              100
  12797.      NLOG            3               3               3
  12798.      NUMSP           64              1               256
  12799.      NUMTIM          16              1               8192
  12800.      NUMTRW          16              1               8192
  12801.      * Semaphore Parameters
  12802.      SEMMAP          10              10              8192
  12803.      SEMMNI          10              10              8192
  12804.      SEMMNS          60              60              8192
  12805.      SEMMNU          30              10              8192
  12806.      SEMMSL          25              25              150
  12807.      SEMOPM          10              10              1024
  12808.      SEMUME          10              10              25
  12809.      SEMVMX          32767           32767           32767
  12810.      SEMAEM          16384           16384           16384
  12811.      * Shared Memory Parameters
  12812.      SHMMAX          524288          131072          2147483647
  12813.      SHMMIN          1               1               1
  12814.      SHMMNI          100             100             2000
  12815.      FILE            0               100             64000
  12816.      NMOUNT          0               4               256
  12817.      NPROC           0               50              16000
  12818.      NREGION         0               500             160000
  12819.  
  12820. We recommend setting these values as follows:
  12821.  
  12822. `NOFILES' should be 4096 or 2048.
  12823.  
  12824. `MAXUP' should be 2048.
  12825.  
  12826. To make changes to the kernel, `cd' to `/etc/conf/bin' and use
  12827. `./idtune' NAME PARAMETER to make the changes. For example, to change
  12828. `SEMMS' to `200', execute these commands as `root':
  12829.  
  12830.      # cd /etc/conf/bin
  12831.      # ./idtune SEMMNS 200
  12832.  
  12833. We recommend tuning the system, but the proper parameter values to use
  12834. depend on the number of users accessing the application or database and
  12835. size the of the database (that is, the used buffer pool). The following
  12836. will affect the following kernel parameters defined in
  12837. `/etc/conf/cf.d/stune':
  12838.  
  12839. `SHMMAX' (recommended setting: 128MB) and `SHMSEG' (recommended
  12840. setting: 15).  These parameters have influence on the MySQL database
  12841. engine to create user buffer pools.
  12842.  
  12843. `NOFILES' and `MAXUP' should be at to at least 2048.
  12844.  
  12845. `MAXPROC' should be set to at least 3000/4000 (depends on number of
  12846. users) or more.
  12847.  
  12848. Also is recommended to use following formula to count value for
  12849. `SEMMSL', `SEMMNS' and `SEMMNU':
  12850.  
  12851.      SEMMSL = 13
  12852.  
  12853. The 13 is what has been found to be the best for both Progress and
  12854. MySQL.
  12855.  
  12856. `SEMMNS' = `SEMMSL' * number of db servers to be run on the system.
  12857.  
  12858. Set `SEMMNS' to the value of `SEMMSL' multiplied by the number of db
  12859. servers (maximum) that you will be running on the system at one time.
  12860.  
  12861.      SEMMNU = SEMMNS
  12862.  
  12863. Set the value of `SEMMNU' to equal the value of `SEMMNS'. You could
  12864. probably set this to 75% of `SEMMNS', but this is a conservative
  12865. estimate.
  12866.  
  12867. You need to at least install the "SCO OpenServer Linker and Application
  12868. Development Libraries" or the OpenServer Development System to use
  12869. `gcc'.  You cannot just use the GCC Dev system without installing one
  12870. of these.
  12871.  
  12872. You should get the FSU Pthreads package and install it first. This can
  12873. be found at
  12874. `http://moss.csc.ncsu.edu/~mueller/ftp/pub/PART/pthreads.tar.gz'.  You
  12875. can also get a precompiled package from
  12876. `ftp://ftp.zenez.com/pub/zenez/prgms/FSU-threads-3.14.tar.gz'.
  12877.  
  12878. FSU Pthreads can be compiled with SCO Unix 4.2 with tcpip, or using
  12879. OpenServer 3.0 or Open Desktop 3.0 (OS 3.0 ODT 3.0) with the SCO
  12880. Development System installed using a good port of GCC 2.5.x. For ODT or
  12881. OS 3.0, you will need a good port of GCC 2.5.x. There are a lot of
  12882. problems without a good port. The port for this product requires the
  12883. SCO Unix Development system. Without it, you are missing the libraries
  12884. and the linker that is needed.  You will also need
  12885. `SCO-3.2v4.2-includes.tar.gz'. This file contains the changes to the
  12886. SCO Development include files that are needed to get MySQL to build.
  12887. You need to replace the existing system include files with these
  12888. modified header files.  They can be obtained from
  12889. `ftp://ftp.zenez.com/pub/zenez/prgms/SCO-3.2v4.2-includes.tar.gz'.
  12890.  
  12891. To build FSU Pthreads on your system, all you should need to do is run
  12892. GNU `make'.  The `Makefile' in FSU-threads-3.14.tar.gz is already set
  12893. up to make FSU-threads.
  12894.  
  12895. You can run `./configure' in the `threads/src' directory and select the
  12896. SCO OpenServer option. This command copies `Makefile.SCO5' to
  12897. `Makefile'.  Then run `make'.
  12898.  
  12899. To install in the default `/usr/include' directory, log in as `root',
  12900. then `cd' to the `thread/src' directory and run `make install'.
  12901.  
  12902. Remember that you must use GNU `make' when making MySQL.
  12903.  
  12904. *Note*: If you don't start `mysqld_safe' as `root', you probably will
  12905. get only the default 110 open files per process. `mysqld' will write a
  12906. note about this in the log file.
  12907.  
  12908. With SCO 3.2V4.2, you should use FSU Pthreads version 3.14 or newer.
  12909. The following `configure' command should work:
  12910.  
  12911.      CFLAGS="-D_XOPEN_XPG4" CXX=gcc CXXFLAGS="-D_XOPEN_XPG4" \
  12912.      ./configure \
  12913.          --prefix=/usr/local/mysql \
  12914.          --with-named-thread-libs="-lgthreads -lsocket -lgen -lgthreads" \
  12915.          --with-named-curses-libs="-lcurses"
  12916.  
  12917. You may get some problems with some include files. In this case, you can
  12918. find new SCO-specific include files at
  12919. `ftp://ftp.zenez.com/pub/zenez/prgms/SCO-3.2v4.2-includes.tar.gz'.
  12920.  
  12921. You should unpack this file in the `include' directory of your MySQL
  12922. source tree.
  12923.  
  12924. SCO development notes:
  12925.  
  12926.    bullet MySQL should automatically detect FSU Pthreads and link
  12927.      `mysqld' with `-lgthreads -lsocket -lgthreads'.
  12928.  
  12929.    bullet The SCO development libraries are re-entrant in FSU Pthreads.
  12930.      SCO claims that its library functions are re-entrant, so they must
  12931.      be re-entrant with FSU Pthreads. FSU Pthreads on OpenServer tries
  12932.      to use the SCO scheme to make re-entrant libraries.
  12933.  
  12934.    bullet FSU Pthreads (at least the version at `ftp::/ftp.zenez.com')
  12935.      comes linked with GNU `malloc'. If you encounter problems with
  12936.      memory usage, make sure that `gmalloc.o' is included in
  12937.      `libgthreads.a' and `libgthreads.so'.
  12938.  
  12939.    bullet In FSU Pthreads, the following system calls are
  12940.      pthreads-aware: `read()', `write()', `getmsg()', `connect()',
  12941.      `accept(),' `select()', and `wait()'.
  12942.  
  12943.    bullet The CSSA-2001-SCO.35.2 (the patch is listed in custom as
  12944.      erg711905-dscr_remap security patch (version 2.0.0)) breaks FSU
  12945.      threads and makes `mysqld' unstable. You have to remove this one
  12946.      if you want to run `mysqld' on an OpenServer 5.0.6 machine.
  12947.  
  12948.    bullet SCO provides operating system patches at
  12949.      `ftp://ftp.sco.com/pub/openserver5' for OpenServer 5.0.x.
  12950.  
  12951.    bullet SCO provides security fixes and `libsocket.so.2' at
  12952.      `ftp://ftp.sco.com/pub/security/OpenServer' and
  12953.      `ftp://ftp.sco.com/pub/security/sse' for OpenServer 5.0.x.
  12954.  
  12955.    bullet Pre-OSR506 security fixes. Also, the `telnetd' fix at
  12956.      `ftp://stage.caldera.com/pub/security/openserver/' or
  12957.      `ftp://stage.caldera.com/pub/security/openserver/CSSA-2001-SCO.10/'
  12958.      as both `libsocket.so.2' and `libresolv.so.1' with instructions for
  12959.      installing on pre-OSR506 systems.
  12960.  
  12961.      It's probably a good idea to install these patches before trying
  12962.      to compile/use MySQL.
  12963.  
  12964.  
  12965. Begining with Legend, OpenServer will have native threads and no 2GB
  12966. file size limit.
  12967.  
  12968. SCO UnixWare Version 7.1.x Notes
  12969. ................................
  12970.  
  12971. We recommend using the latest production release of MySQL.  Currently
  12972. this is MySQL 4.0.x.  Should you choose to use an older release of
  12973. MySQL on UnixWare 7.1.x, you must use a version of MySQL at least as
  12974. recent as 3.22.13 to get fixes for some portability and OS problems.
  12975.  
  12976. We have been able to compile MySQL with the following `configure'
  12977. command on UnixWare Version 7.1.x:
  12978.  
  12979.      CC="cc" CFLAGS="-I/usr/local/include" \
  12980.      CXX="CC" CXXFLAGS="-I/usr/local/include" \
  12981.      ./configure --prefix=/usr/local/mysql \
  12982.          --enable-thread-safe-client --with-berkeley-db=./bdb \
  12983.          --with-innodb --with-openssl --with-extra-charsets=complex
  12984.  
  12985. If you want to use `gcc', you must use `gcc' 2.95.3 or newer.
  12986.  
  12987.      CC=gcc CXX=g++ ./configure --prefix=/usr/local/mysql
  12988.  
  12989. SCO provides operating system patches at
  12990. `ftp://ftp.sco.com/pub/unixware7' for UnixWare 7.1.1,
  12991. `ftp://ftp.sco.com/pub/unixware7/713/' for UnixWare 7.1.3,
  12992. `ftp://ftp.sco.com/pub/unixware7/714/' for UnixWare 7.1.4, and
  12993. `ftp://ftp.sco.com/pub/openunix8' for OpenUNIX 8.0.0.
  12994.  
  12995. SCO provides information about security fixes at
  12996. `ftp://ftp.sco.com/pub/security/OpenUNIX' for OpenUNIX and
  12997. `ftp://ftp.sco.com/pub/security/UnixWare' for UnixWare.
  12998.  
  12999. By default, the maximum file size on a UnixWare 7 system is 1GB.  Many
  13000. OS utilities have a limitation of 2GB.  The maximum possible file size
  13001. on UnixWare 7 is 1TB with VXFS.
  13002.  
  13003. To enable large file support on UnixWare 7.1.x, run `fsadm'.
  13004.  
  13005.      # fsadm -Fvxfs -o largefiles /
  13006.      # fsadm /                    * Note
  13007.      # ulimit unlimited
  13008.      # cd /etc/conf/bin
  13009.      # ./idtune SFSZLIM 0x7FFFFFFF            ** Note
  13010.      # ./idtune HFSZLIM 0x7FFFFFFF            ** Note
  13011.      # ./idbuild -B
  13012.      
  13013.      * This should report "largefiles".
  13014.      ** 0x7FFFFFFF represents infinity for these values.
  13015.  
  13016. Reboot the system using `shutdown'.
  13017.  
  13018. By default, the entries in `/etc/conf/cf.d/mtune' are set to:
  13019.  
  13020.      Value           Default         Min             Max
  13021.      -----           -------         ---             ---
  13022.      SVMMLIM         0x9000000       0x1000000       0x7FFFFFFF
  13023.      HVMMLIM         0x9000000       0x1000000       0x7FFFFFFF
  13024.      SSTKLIM         0x1000000       0x2000          0x7FFFFFFF
  13025.      HSTKLIM         0x1000000       0x2000          0x7FFFFFFF
  13026.  
  13027. We recommend setting these values as follows:
  13028.  
  13029.      SDATLIM 0x7FFFFFFF
  13030.      HDATLIM 0x7FFFFFFF
  13031.      SSTKLIM 0x7FFFFFFF
  13032.      HSTKLIM 0x7FFFFFFF
  13033.      SVMMLIM 0x7FFFFFFF
  13034.      HVMMLIM 0x7FFFFFFF
  13035.      SFNOLIM 2048
  13036.      HFNOLIM 2048
  13037.  
  13038. We recommend tuning the system, but the proper parameter values to use
  13039. depend on the number of users accessing the application or database and
  13040. size the of the database (that is, the used buffer pool). The following
  13041. will affect the following kernel parameters defined in
  13042. `/etc/conf/cf.d/stune':
  13043.  
  13044. `SHMMAX' (recommended setting: 128MB) and `SHMSEG' (recommended
  13045. setting: 15).  These parameters have influence on the MySQL database
  13046. engine to create user buffer pools.
  13047.  
  13048. `SFNOLIM' and `HFNOLIM' should be at maximum 2048.
  13049.  
  13050. `NPROC' should be set to at least 3000/4000 (depends on number of
  13051. users).
  13052.  
  13053. Also is recommended to use following formula to count value for
  13054. `SEMMSL', `SEMMNS', and `SEMMNU':
  13055.  
  13056.      SEMMSL = 13
  13057.  
  13058. 13 is what has been found to be the best for both Progress and MySQL.
  13059.  
  13060. `SEMMNS' = `SEMMSL' * number of db servers to be run on the system.
  13061.  
  13062. Set `SEMMNS' to the value of `SEMMSL' multiplied by the number of db
  13063. servers (maximum) that you will be running on the system at one time.
  13064.  
  13065. `SEMMNU' = `SEMMNS'
  13066.  
  13067. Set the value of `SEMMNU' to equal the value of `SEMMNS'. You could
  13068. probably set this to 75% of `SEMMNS', but this is a conservative
  13069. estimate.
  13070.  
  13071. OS/2 Notes
  13072. ----------
  13073.  
  13074. MySQL uses quite a few open files. Because of this, you should add
  13075. something like the following to your `CONFIG.SYS' file:
  13076.  
  13077.      SET EMXOPT=-c -n -h1024
  13078.  
  13079. If you don't do this, you will probably run into the following error:
  13080.  
  13081.      File 'XXXX' not found (Errcode: 24)
  13082.  
  13083. When using MySQL with OS/2 Warp 3, FixPack 29 or above is required.
  13084. With OS/2 Warp 4, FixPack 4 or above is required. This is a requirement
  13085. of the Pthreads library.  MySQL must be installed on a partition with a
  13086. type that supports long filenames, such as HPFS, FAT32, and so on.
  13087.  
  13088. The `INSTALL.CMD' script must be run from OS/2's own `CMD.EXE' and may
  13089. not work with replacement shells such as `4OS2.EXE'.
  13090.  
  13091. The `scripts/mysql-install-db' script has been renamed.  It is now
  13092. called `install.cmd' and is a REXX script, which will set up the default
  13093. MySQL security settings and create the WorkPlace Shell icons for MySQL.
  13094.  
  13095. Dynamic module support is compiled in but not fully tested. Dynamic
  13096. modules should be compiled using the Pthreads runtime library.
  13097.  
  13098.      gcc -Zdll -Zmt -Zcrtdll=pthrdrtl -I../include -I../regex -I.. \
  13099.          -o example udf_example.cc -L../lib -lmysqlclient udf_example.def
  13100.      mv example.dll example.udf
  13101.  
  13102. *Note*: Due to limitations in OS/2, UDF module name stems must not
  13103. exceed eight characters. Modules are stored in the `/mysql2/udf'
  13104. directory; the `safe-mysqld.cmd' script will put this directory in the
  13105. `BEGINLIBPATH' environment variable. When using UDF modules, specified
  13106. extensions are ignored--it is assumed to be `.udf'.  For example, in
  13107. Unix, the shared module might be named `example.so' and you would load
  13108. a function from it like this:
  13109.  
  13110.      mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME 'example.so';
  13111.  
  13112. In OS/2, the module would be named `example.udf', but you would not
  13113. specify the module extension:
  13114.  
  13115.      mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME 'example';
  13116.  
  13117. BeOS Notes
  13118. ----------
  13119.  
  13120. We have in the past talked with some BeOS developers who have said that
  13121. MySQL is 80% ported to BeOS, but we haven't heard from them in a while.
  13122.  
  13123. Perl Installation Notes
  13124. =======================
  13125.  
  13126. Perl support for MySQL is provided by means of the `DBI'/`DBD' client
  13127. interface. The interface requires Perl Version 5.6.0 or later.  It
  13128. _will not work_ if you have an older version of Perl.
  13129.  
  13130. If you want to use transactions with Perl DBI, you need to have
  13131. `DBD::mysql' version 1.2216 or newer. Version 2.9003 or newer is
  13132. recommended.
  13133.  
  13134. If you are using the MySQL 4.1 client library, you must use
  13135. `DBD::mysql' 2.9003 or newer.
  13136.  
  13137. As of MySQL 3.22.8, Perl support is no longer included with MySQL
  13138. distributions. You can obtain the necessary modules from
  13139. `http://search.cpan.org' for Unix, or by using the ActiveState `ppm'
  13140. program on Windows. The following sections describe how to do this.
  13141.  
  13142. Perl support for MySQL must be installed if you want to run the MySQL
  13143. benchmark scripts.  *Note MySQL Benchmarks::.
  13144.  
  13145. Installing Perl on Unix
  13146. -----------------------
  13147.  
  13148. MySQL Perl support requires that you've installed MySQL client
  13149. programming support (libraries and header files).  Most installation
  13150. methods install the necessary files. However, if you installed MySQL
  13151. from RPM files on Linux, be sure that you've installed the developer
  13152. RPM.  The client programs are in the client RPM, but client programming
  13153. support is in the developer RPM.
  13154.  
  13155. If you want to install Perl support, the files you will need can be
  13156. obtained from the CPAN (Comprehensive Perl Archive Network) at
  13157. `http://search.cpan.org'.
  13158.  
  13159. The easiest way to install Perl modules on Unix is to use the `CPAN'
  13160. module. For example:
  13161.  
  13162.      shell> perl -MCPAN -e shell
  13163.      cpan> install DBI
  13164.      cpan> install DBD::mysql
  13165.  
  13166. The `DBD::mysql' installation runs a number of tests.  These tests
  13167. require being able to connect to the local MySQL server as the
  13168. anonymous user with no password. If you have removed anonymous accounts
  13169. or assigned them passwords, the tests fail. You can use `force install
  13170. DBD::mysql' to ignore the failed tests.
  13171.  
  13172. `DBI' requires the `Data::Dumper' module. It may already be installed;
  13173. if not, you should install it before installing `DBI'.
  13174.  
  13175. It is also possible to download the module distributions in the form of
  13176. compressed `tar' archives and build the modules manually. For example,
  13177. to unpack and build a DBI distribution, use a procedure such as this:
  13178.  
  13179.   1. Unpack the distribution into the current directory:
  13180.           shell> gunzip < DBI-VERSION.tar.gz | tar xvf -
  13181.      This command creates a directory named `DBI-VERSION'.
  13182.  
  13183.   2. Change location into the top-level directory of the unpacked
  13184.      distribution:
  13185.           shell> cd DBI-VERSION
  13186.  
  13187.   3. Build the distribution and compile everything:
  13188.           shell> perl Makefile.PL
  13189.           shell> make
  13190.           shell> make test
  13191.           shell> make install
  13192.  
  13193. The `make test' command is important because it verifies that the
  13194. module is working.  Note that when you run that command during the
  13195. `DBD::mysql' installation to exercise the interface code, the MySQL
  13196. server must be running or the test will fail.
  13197.  
  13198. It is a good idea to rebuild and reinstall the `DBD::mysql'
  13199. distribution whenever you install a new release of MySQL, particularly
  13200. if you notice symptoms such as that all your `DBI' scripts fail after
  13201. you upgrade MySQL.
  13202.  
  13203. If you don't have access rights to install Perl modules in the system
  13204. directory or if you want to install local Perl modules, the following
  13205. reference may be useful:
  13206. `http://servers.digitaldaze.com/extensions/perl/modules.html#modules'
  13207.  
  13208. Look under the heading "Installing New Modules that Require Locally
  13209. Installed Modules."
  13210.  
  13211. Installing ActiveState Perl on Windows
  13212. --------------------------------------
  13213.  
  13214. On Windows, you should do the following to install the MySQL `DBD'
  13215. module with ActiveState Perl:
  13216.  
  13217.    * Get ActiveState Perl from
  13218.      `http://www.activestate.com/Products/ActivePerl/' and install it.
  13219.  
  13220.    * Open a console window (a "DOS window").
  13221.  
  13222.    * If required, set the `HTTP_proxy' variable. For example, you might
  13223.      try:
  13224.  
  13225.           set HTTP_proxy=my.proxy.com:3128
  13226.  
  13227.    * Start the PPM program:
  13228.  
  13229.           C:\> C:\perl\bin\ppm.pl
  13230.  
  13231.    * If you have not already done so, install `DBI':
  13232.  
  13233.           ppm> install DBI
  13234.  
  13235.    * If this succeeds, run the following command:
  13236.  
  13237.           install \
  13238.           ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd
  13239.  
  13240. This procedure should work at least with ActiveState Perl Version 5.6.
  13241.  
  13242. If you can't get the procedure to work, you should instead install the
  13243. MyODBC driver and connect to the MySQL server through ODBC:
  13244.  
  13245.      use DBI;
  13246.      $dbh= DBI->connect("DBI:ODBC:$dsn",$user,$password) ||
  13247.        die "Got error $DBI::errstr when connecting to $dsn\n";
  13248.  
  13249. Problems Using the Perl `DBI'/`DBD' Interface
  13250. ---------------------------------------------
  13251.  
  13252. If Perl reports that it can't find the `../mysql/mysql.so' module, then
  13253. the problem is probably that Perl can't locate the shared library
  13254. `libmysqlclient.so'.
  13255.  
  13256. You should be able to fix this by one of the following methods:
  13257.  
  13258.    * Compile the `DBD::mysql' distribution with `perl Makefile.PL
  13259.      -static -config' rather than `perl Makefile.PL'.
  13260.  
  13261.    * Copy `libmysqlclient.so' to the directory where your other shared
  13262.      libraries are located (probably `/usr/lib' or `/lib').
  13263.  
  13264.    * Modify the `-L' options used to compile `DBD::mysql' to reflect
  13265.      the actual location of `libmysqlclient.so'.
  13266.  
  13267.    * On Linux, you can add the pathname of the directory where
  13268.      `libmysqlclient.so' is located to the `/etc/ld.so.conf' file.
  13269.  
  13270.    * Add the pathname of the directory where `libmysqlclient.so' is
  13271.      located to the `LD_RUN_PATH' environment variable. Some systems use
  13272.      `LD_LIBRARY_PATH' instead.
  13273.  
  13274. Note that you may also need to modify the `-L' options if there are
  13275. other libraries that the linker fails to find. For example, if the
  13276. linker cannot find `libc' because it is in `/lib' and the link command
  13277. specifies `-L/usr/lib', change the `-L' option to `-L/lib' or add
  13278. `-L/lib' to the existing link command.
  13279.  
  13280. If you get the following errors from `DBD::mysql', you are probably
  13281. using `gcc' (or using an old binary compiled with `gcc'):
  13282.  
  13283.      /usr/bin/perl: can't resolve symbol '__moddi3'
  13284.      /usr/bin/perl: can't resolve symbol '__divdi3'
  13285.  
  13286. Add `-L/usr/lib/gcc-lib/... -lgcc' to the link command when the
  13287. `mysql.so' library gets built (check the output from `make' for
  13288. `mysql.so' when you compile the Perl client).  The `-L' option should
  13289. specify the pathname of the directory where `libgcc.a' is located on
  13290. your system.
  13291.  
  13292. Another cause of this problem may be that Perl and MySQL aren't both
  13293. compiled with `gcc'.  In this case, you can solve the mismatch by
  13294. compiling both with `gcc'.
  13295.  
  13296. You may see the following error from `DBD::mysql' when you run the
  13297. tests:
  13298.  
  13299.      t/00base............install_driver(mysql) failed:
  13300.      Can't load '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql:
  13301.      ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol:
  13302.      uncompress at /usr/lib/perl5/5.00503/i586-linux/DynaLoader.pm line 169.
  13303.  
  13304. This means that you need to include the `-lz' compression library on the
  13305. link line. That can be done by changing the following line in the file
  13306. `lib/DBD/mysql/Install.pm':
  13307.  
  13308.      $sysliblist .= " -lm";
  13309.  
  13310. Change that line to:
  13311.  
  13312.      $sysliblist .= " -lm -lz";
  13313.  
  13314. After this, you _must_ run `make realclean' and then proceed with the
  13315. installation from the beginning.
  13316.  
  13317. If you want to install DBI on SCO, you have to edit the `Makefile' in
  13318. DBI-XXX and each subdirectory.  Note that the following assumes `gcc'
  13319. 2.95.2 or newer:
  13320.  
  13321.      OLD:                                  NEW:
  13322.      CC = cc                               CC = gcc
  13323.      CCCDLFLAGS = -KPIC -W1,-Bexport       CCCDLFLAGS = -fpic
  13324.      CCDLFLAGS = -wl,-Bexport              CCDLFLAGS =
  13325.      
  13326.      LD = ld                               LD = gcc -G -fpic
  13327.      LDDLFLAGS = -G -L/usr/local/lib       LDDLFLAGS = -L/usr/local/lib
  13328.      LDFLAGS = -belf -L/usr/local/lib      LDFLAGS = -L/usr/local/lib
  13329.      
  13330.      LD = ld                               LD = gcc -G -fpic
  13331.      OPTIMISE = -Od                        OPTIMISE = -O1
  13332.      
  13333.      OLD:
  13334.      CCCFLAGS = -belf -dy -w0 -U M_XENIX -DPERL_SCO5 -I/usr/local/include
  13335.      
  13336.      NEW:
  13337.      CCFLAGS = -U M_XENIX -DPERL_SCO5 -I/usr/local/include
  13338.  
  13339. These changes are necessary because the Perl dynaloader will not load
  13340. the `DBI' modules if they were compiled with `icc' or `cc'.
  13341.  
  13342. If you want to use the Perl module on a system that doesn't support
  13343. dynamic linking (such as SCO), you can generate a static version of
  13344. Perl that includes `DBI' and `DBD::mysql'.  The way this works is that
  13345. you generate a version of Perl with the `DBI' code linked in and
  13346. install it on top of your current Perl.  Then you use that to build a
  13347. version of Perl that additionally has the `DBD' code linked in, and
  13348. install that.
  13349.  
  13350. On SCO, you must have the following environment variables set:
  13351.  
  13352.      LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/progressive/lib
  13353.  
  13354. Or:
  13355.  
  13356.      LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:\
  13357.          /usr/progressive/lib:/usr/skunk/lib
  13358.      LIBPATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:\
  13359.          /usr/progressive/lib:/usr/skunk/lib
  13360.      MANPATH=scohelp:/usr/man:/usr/local1/man:/usr/local/man:\
  13361.          /usr/skunk/man:
  13362.  
  13363. First, create a Perl that includes a statically linked `DBI' module by
  13364. running these commands in the directory where your `DBI' distribution is
  13365. located:
  13366.  
  13367.      shell> perl Makefile.PL -static -config
  13368.      shell> make
  13369.      shell> make install
  13370.      shell> make perl
  13371.  
  13372. Then you must install the new Perl. The output of `make perl' will
  13373. indicate the exact `make' command you will need to execute to perform
  13374. the installation.  On SCO, this is `make -f Makefile.aperl inst_perl
  13375. MAP_TARGET=perl'.
  13376.  
  13377. Next, use the just-created Perl to create another Perl that also
  13378. includes a statically linked `DBD::mysql' by running these commands in
  13379. the directory where your `DBD::mysql' distribution is located:
  13380.  
  13381.      shell> perl Makefile.PL -static -config
  13382.      shell> make
  13383.      shell> make install
  13384.      shell> make perl
  13385.  
  13386. Finally, you should install this new Perl.  Again, the output of `make
  13387. perl' indicates the command to use.
  13388.  
  13389. MySQL Tutorial
  13390. **************
  13391.  
  13392. This chapter provides a tutorial introduction to MySQL by showing how
  13393. to use the `mysql' client program to create and use a simple database.
  13394. `mysql' (sometimes referred to as the "terminal monitor" or just
  13395. "monitor") is an interactive program that allows you to connect to a
  13396. MySQL server, run queries, and view the results.  `mysql' may also be
  13397. used in batch mode: you place your queries in a file beforehand, then
  13398. tell `mysql' to execute the contents of the file.  Both ways of using
  13399. `mysql' are covered here.
  13400.  
  13401. To see a list of options provided by `mysql', invoke it with the
  13402. `--help' option:
  13403.  
  13404.      shell> mysql --help
  13405.  
  13406. This chapter assumes that `mysql' is installed on your machine and that
  13407. a MySQL server is available to which you can connect.  If this is not
  13408. true, contact your MySQL administrator.  (If *you* are the
  13409. administrator, you will need to consult other sections of this manual.)
  13410.  
  13411. This chapter describes the entire process of setting up and using a
  13412. database.  If you are interested only in accessing an already-existing
  13413. database, you may want to skip over the sections that describe how to
  13414. create the database and the tables it contains.
  13415.  
  13416. Because this chapter is tutorial in nature, many details are necessarily
  13417. omitted.  Consult the relevant sections of the manual for more
  13418. information on the topics covered here.
  13419.  
  13420. Connecting to and Disconnecting from the Server
  13421. ===============================================
  13422.  
  13423. To connect to the server, you'll usually need to provide a MySQL
  13424. username when you invoke `mysql' and, most likely, a password.  If the
  13425. server runs on a machine other than the one where you log in, you'll
  13426. also need to specify a hostname.  Contact your administrator to find
  13427. out what connection parameters you should use to connect (that is, what
  13428. host, username, and password to use).  Once you know the proper
  13429. parameters, you should be able to connect like this:
  13430.  
  13431.      shell> mysql -h HOST -u USER -p
  13432.      Enter password: ********
  13433.  
  13434. `host' and `user' represent the hostname where your MySQL server is
  13435. running and the username of your MySQL account.  Substitute appropriate
  13436. values for your setup.  The `********' represents your password; enter
  13437. it when `mysql' displays the `Enter password:' prompt.
  13438.  
  13439. If that works, you should see some introductory information followed by
  13440. a `mysql>' prompt:
  13441.  
  13442.      shell> mysql -h HOST -u USER -p
  13443.      Enter password: ********
  13444.      Welcome to the MySQL monitor.  Commands end with ; or \g.
  13445.      Your MySQL connection id is 25338 to server version: 4.0.14-log
  13446.      
  13447.      Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  13448.      
  13449.      mysql>
  13450.  
  13451. The prompt tells you that `mysql' is ready for you to enter commands.
  13452.  
  13453. Some MySQL installations allow users to connect as the anonymous
  13454. (unnamed) user to the server running on the local host.  If this is the
  13455. case on your machine, you should be able to connect to that server by
  13456. invoking `mysql' without any options:
  13457.  
  13458.      shell> mysql
  13459.  
  13460. After you have connected successfully, you can disconnect any time by
  13461. typing `QUIT' (or `\q') at the `mysql>' prompt:
  13462.  
  13463.      mysql> QUIT
  13464.      Bye
  13465.  
  13466. On Unix, you can also disconnect by pressing Control-D.
  13467.  
  13468. Most examples in the following sections assume that you are connected
  13469. to the server.  They indicate this by the `mysql>' prompt.
  13470.  
  13471. Entering Queries
  13472. ================
  13473.  
  13474. Make sure that you are connected to the server, as discussed in the
  13475. previous section.  Doing so will not in itself select any database to
  13476. work with, but that's okay.  At this point, it's more important to find
  13477. out a little about how to issue queries than to jump right in creating
  13478. tables, loading data into them, and retrieving data from them.  This
  13479. section describes the basic principles of entering commands, using
  13480. several queries you can try out to familiarize yourself with how
  13481. `mysql' works.
  13482.  
  13483. Here's a simple command that asks the server to tell you its version
  13484. number and the current date.  Type it in as shown here following the
  13485. `mysql>' prompt and press Enter:
  13486.  
  13487.      mysql> SELECT VERSION(), CURRENT_DATE;
  13488.      +--------------+--------------+
  13489.      | VERSION()    | CURRENT_DATE |
  13490.      +--------------+--------------+
  13491.      | 3.22.20a-log | 1999-03-19   |
  13492.      +--------------+--------------+
  13493.      1 row in set (0.01 sec)
  13494.      mysql>
  13495.  
  13496. This query illustrates several things about `mysql':
  13497.  
  13498.    * A command normally consists of an SQL statement followed by a
  13499.      semicolon.  (There are some exceptions where a semicolon may be
  13500.      omitted.  `QUIT', mentioned earlier, is one of them.  We'll get to
  13501.      others later.)
  13502.  
  13503.    * When you issue a command, `mysql' sends it to the server for
  13504.      execution and displays the results, then prints another `mysql>'
  13505.      prompt to indicate that it is ready for another command.
  13506.  
  13507.    * `mysql' displays query output in tabular form (rows and columns).
  13508.      The first row contains labels for the columns.  The rows following
  13509.      are the query results.  Normally, column labels are the names of
  13510.      the columns you fetch from database tables.  If you're retrieving
  13511.      the value of an expression rather than a table column (as in the
  13512.      example just shown), `mysql' labels the column using the
  13513.      expression itself.
  13514.  
  13515.    * `mysql' shows how many rows were returned and how long the query
  13516.      took to execute, which gives you a rough idea of server
  13517.      performance.  These values are imprecise because they represent
  13518.      wall clock time (not CPU or machine time), and because they are
  13519.      affected by factors such as server load and network latency.  (For
  13520.      brevity, the "rows in set" line is not shown in the remaining
  13521.      examples in this chapter.)
  13522.  
  13523. Keywords may be entered in any lettercase.  The following queries are
  13524. equivalent:
  13525.  
  13526.      mysql> SELECT VERSION(), CURRENT_DATE;
  13527.      mysql> select version(), current_date;
  13528.      mysql> SeLeCt vErSiOn(), current_DATE;
  13529.  
  13530. Here's another query.  It demonstrates that you can use `mysql' as a
  13531. simple calculator:
  13532.  
  13533.      mysql> SELECT SIN(PI()/4), (4+1)*5;
  13534.      +-------------+---------+
  13535.      | SIN(PI()/4) | (4+1)*5 |
  13536.      +-------------+---------+
  13537.      |    0.707107 |      25 |
  13538.      +-------------+---------+
  13539.  
  13540. The queries shown thus far have been relatively short, single-line
  13541. statements.  You can even enter multiple statements on a single line.
  13542. Just end each one with a semicolon:
  13543.  
  13544.      mysql> SELECT VERSION(); SELECT NOW();
  13545.      +--------------+
  13546.      | VERSION()    |
  13547.      +--------------+
  13548.      | 3.22.20a-log |
  13549.      +--------------+
  13550.      
  13551.      +---------------------+
  13552.      | NOW()               |
  13553.      +---------------------+
  13554.      | 1999-03-19 00:15:33 |
  13555.      +---------------------+
  13556.  
  13557. A command need not be given all on a single line, so lengthy commands
  13558. that require several lines are not a problem.  `mysql' determines where
  13559. your statement ends by looking for the terminating semicolon, not by
  13560. looking for the end of the input line.  (In other words, `mysql'
  13561. accepts free-format input:  it collects input lines but does not
  13562. execute them until it sees the semicolon.)
  13563.  
  13564. Here's a simple multiple-line statement:
  13565.  
  13566.      mysql> SELECT
  13567.          -> USER()
  13568.          -> ,
  13569.          -> CURRENT_DATE;
  13570.      +--------------------+--------------+
  13571.      | USER()             | CURRENT_DATE |
  13572.      +--------------------+--------------+
  13573.      | joesmith@localhost | 1999-03-18   |
  13574.      +--------------------+--------------+
  13575.  
  13576. In this example, notice how the prompt changes from `mysql>' to `->'
  13577. after you enter the first line of a multiple-line query.  This is how
  13578. `mysql' indicates that it hasn't seen a complete statement and is
  13579. waiting for the rest.  The prompt is your friend, because it provides
  13580. valuable feedback.  If you use that feedback, you will always be aware
  13581. of what `mysql' is waiting for.
  13582.  
  13583. If you decide you don't want to execute a command that you are in the
  13584. process of entering, cancel it by typing `\c':
  13585.  
  13586.      mysql> SELECT
  13587.          -> USER()
  13588.          -> \c
  13589.      mysql>
  13590.  
  13591. Here, too, notice the prompt.  It switches back to `mysql>' after you
  13592. type `\c', providing feedback to indicate that `mysql' is ready for a
  13593. new command.
  13594.  
  13595. The following table shows each of the prompts you may see and
  13596. summarizes what they mean about the state that `mysql' is in:
  13597.  
  13598. *Prompt**Meaning*
  13599. `mysql>'Ready for new command.
  13600. `       Waiting for next line of multiple-line command.
  13601. ->'     
  13602. `       Waiting for next line, collecting a string that begins
  13603. '>'     with a single quote (`'').
  13604. `       Waiting for next line, collecting a string that begins
  13605. ">'     with a double quote (`"').
  13606. `       Waiting for next line, collecting an identifier that
  13607. `>'     begins with a backtick (``').
  13608.  
  13609. Multiple-line statements commonly occur by accident when you intend to
  13610. issue a command on a single line, but forget the terminating semicolon.
  13611. In this case, `mysql' waits for more input:
  13612.  
  13613.      mysql> SELECT USER()
  13614.          ->
  13615.  
  13616. If this happens to you (you think you've entered a statement but the
  13617. only response is a `->' prompt), most likely `mysql' is waiting for the
  13618. semicolon.  If you don't notice what the prompt is telling you, you
  13619. might sit there for a while before realising what you need to do.
  13620. Enter a semicolon to complete the statement, and `mysql' will execute
  13621. it:
  13622.  
  13623.      mysql> SELECT USER()
  13624.          -> ;
  13625.      +--------------------+
  13626.      | USER()             |
  13627.      +--------------------+
  13628.      | joesmith@localhost |
  13629.      +--------------------+
  13630.  
  13631. The `'>' and `">' prompts occur during string collection.  In MySQL,
  13632. you can write strings surrounded by either `'' or `"' characters (for
  13633. example, `'hello'' or `"goodbye"'), and `mysql' lets you enter strings
  13634. that span multiple lines.  When you see a `'>' or `">' prompt, it means
  13635. that you've entered a line containing a string that begins with a `''
  13636. or `"' quote character, but have not yet entered the matching quote
  13637. that terminates the string.  That's fine if you really are entering a
  13638. multiple-line string, but how likely is that?  Not very.  More often,
  13639. the `'>' and `">' prompts indicate that you've inadvertantly left out a
  13640. quote character.  For example:
  13641.  
  13642.      mysql> SELECT * FROM my_table WHERE name = 'Smith AND age < 30;
  13643.          '>
  13644.  
  13645. If you enter this `SELECT' statement, then press Enter and wait for the
  13646. result, nothing will happen.  Instead of wondering why this query takes
  13647. so long, notice the clue provided by the `'>' prompt.  It tells you
  13648. that `mysql' expects to see the rest of an unterminated string.  (Do
  13649. you see the error in the statement?  The string `'Smith' is missing the
  13650. second quote.)
  13651.  
  13652. At this point, what do you do?  The simplest thing is to cancel the
  13653. command.  However, you cannot just type `\c' in this case, because
  13654. `mysql' interprets it as part of the string that it is collecting!
  13655. Instead, enter the closing quote character (so `mysql' knows you've
  13656. finished the string), then type `\c':
  13657.  
  13658.      mysql> SELECT * FROM my_table WHERE name = 'Smith AND age < 30;
  13659.          '> '\c
  13660.      mysql>
  13661.  
  13662. The prompt changes back to `mysql>', indicating that `mysql' is ready
  13663. for a new command.
  13664.  
  13665. The ``>' prompt is similar to th `'>' and `">' prompts, but indicates
  13666. that you have begun but not completed a backtick-quoted identifier.
  13667.  
  13668. It's important to know what the `'>', `">', and ``>' prompts signify,
  13669. because if you mistakenly enter an unterminated string, any further
  13670. lines you type will appear to be ignored by `mysql'--including a line
  13671. containing `QUIT'!  This can be quite confusing, especially if you
  13672. don't know that you need to supply the terminating quote before you can
  13673. cancel the current command.
  13674.  
  13675. Creating and Using a Database
  13676. =============================
  13677.  
  13678. Now that you know how to enter commands, it's time to access a database.
  13679.  
  13680. Suppose that you have several pets in your home (your menagerie) and
  13681. you'd like to keep track of various types of information about them.
  13682. You can do so by creating tables to hold your data and loading them
  13683. with the desired information.  Then you can answer different sorts of
  13684. questions about your animals by retrieving data from the tables.  This
  13685. section shows you how to:
  13686.  
  13687.    * Create a database
  13688.  
  13689.    * Create a table
  13690.  
  13691.    * Load data into the table
  13692.  
  13693.    * Retrieve data from the table in various ways
  13694.  
  13695.    * Use multiple tables
  13696.  
  13697. The menagerie database will be simple (deliberately), but it is not
  13698. difficult to think of real-world situations in which a similar type of
  13699. database might be used.  For example, a database like this could be
  13700. used by a farmer to keep track of livestock, or by a veterinarian to
  13701. keep track of patient records.  A menagerie distribution containing
  13702. some of the queries and sample data used in the following sections can
  13703. be obtained from the MySQL Web site.  It's available in either
  13704. compressed `tar' format
  13705. (`http://www.mysql.com/Downloads/Contrib/Examples/menagerie.tar.gz') or
  13706. Zip format
  13707. (`http://www.mysql.com/Downloads/Contrib/Examples/menagerie.zip').
  13708.  
  13709. Use the `SHOW' statement to find out what databases currently exist on
  13710. the server:
  13711.  
  13712.      mysql> SHOW DATABASES;
  13713.      +----------+
  13714.      | Database |
  13715.      +----------+
  13716.      | mysql    |
  13717.      | test     |
  13718.      | tmp      |
  13719.      +----------+
  13720.  
  13721. The list of databases is probably different on your machine, but the
  13722. `mysql' and `test' databases are likely to be among them.  The `mysql'
  13723. database is required because it describes user access privileges.  The
  13724. `test' database is often provided as a workspace for users to try
  13725. things out.
  13726.  
  13727. Note that you may not see all databases if you don't have the `SHOW
  13728. DATABASES' privilege. *Note `GRANT': GRANT.
  13729.  
  13730. If the `test' database exists, try to access it:
  13731.  
  13732.      mysql> USE test
  13733.      Database changed
  13734.  
  13735. Note that `USE', like `QUIT', does not require a semicolon.  (You can
  13736. terminate such statements with a semicolon if you like; it does no
  13737. harm.)  The `USE' statement is special in another way, too:  it must be
  13738. given on a single line.
  13739.  
  13740. You can use the `test' database (if you have access to it) for the
  13741. examples that follow, but anything you create in that database can be
  13742. removed by anyone else with access to it.  For this reason, you should
  13743. probably ask your MySQL administrator for permission to use a database
  13744. of your own.  Suppose that you want to call yours `menagerie'.  The
  13745. administrator needs to execute a command like this:
  13746.  
  13747.      mysql> GRANT ALL ON menagerie.* TO 'your_mysql_name'@'your_client_host';
  13748.  
  13749. where `your_mysql_name' is the MySQL username assigned to you and
  13750. `your_client_host' is the host from which you connect to the server.
  13751.  
  13752. Creating and Selecting a Database
  13753. ---------------------------------
  13754.  
  13755. If the administrator creates your database for you when setting up your
  13756. permissions, you can begin using it.  Otherwise, you need to create it
  13757. yourself:
  13758.  
  13759.      mysql> CREATE DATABASE menagerie;
  13760.  
  13761. Under Unix, database names are case sensitive (unlike SQL keywords), so
  13762. you must always refer to your database as `menagerie', not as
  13763. `Menagerie', `MENAGERIE', or some other variant.  This is also true for
  13764. table names.  (Under Windows, this restriction does not apply, although
  13765. you must refer to databases and tables using the same lettercase
  13766. throughout a given query.)
  13767.  
  13768. Creating a database does not select it for use; you must do that
  13769. explicitly.  To make `menagerie' the current database, use this command:
  13770.  
  13771.      mysql> USE menagerie
  13772.      Database changed
  13773.  
  13774. Your database needs to be created only once, but you must select it for
  13775. use each time you begin a `mysql' session.  You can do this by issuing a
  13776. `USE' statement as shown in the example.  Alternatively, you can select
  13777. the database on the command line when you invoke `mysql'.  Just specify
  13778. its name after any connection parameters that you might need to
  13779. provide.  For example:
  13780.  
  13781.      shell> mysql -h HOST -u USER -p menagerie
  13782.      Enter password: ********
  13783.  
  13784. Note that `menagerie' is not your password on the command just shown.
  13785. If you want to supply your password on the command line after the `-p'
  13786. option, you must do so with no intervening space (for example, as
  13787. `-pmypassword', not as `-p mypassword').  However, putting your
  13788. password on the command line is not recommended, because doing so
  13789. exposes it to snooping by other users logged in on your machine.
  13790.  
  13791. Creating a Table
  13792. ----------------
  13793.  
  13794. Creating the database is the easy part, but at this point it's empty, as
  13795. `SHOW TABLES' will tell you:
  13796.  
  13797.      mysql> SHOW TABLES;
  13798.      Empty set (0.00 sec)
  13799.  
  13800. The harder part is deciding what the structure of your database should
  13801. be: what tables you will need and what columns will be in each of them.
  13802.  
  13803. You'll want a table that contains a record for each of your pets.  This
  13804. can be called the `pet' table, and it should contain, as a bare minimum,
  13805. each animal's name.  Because the name by itself is not very
  13806. interesting, the table should contain other information.  For example,
  13807. if more than one person in your family keeps pets, you might want to
  13808. list each animal's owner.  You might also want to record some basic
  13809. descriptive information such as species and sex.
  13810.  
  13811. How about age?  That might be of interest, but it's not a good thing to
  13812. store in a database.  Age changes as time passes, which means you'd
  13813. have to update your records often.  Instead, it's better to store a
  13814. fixed value such as date of birth.  Then, whenever you need age, you
  13815. can calculate it as the difference between the current date and the
  13816. birth date.  MySQL provides functions for doing date arithmetic, so
  13817. this is not difficult.  Storing birth date rather than age has other
  13818. advantages, too:
  13819.  
  13820.    * You can use the database for tasks such as generating reminders
  13821.      for upcoming pet birthdays.  (If you think this type of query is
  13822.      somewhat silly, note that it is the same question you might ask in
  13823.      the context of a business database to identify clients to whom
  13824.      you'll soon need to send out birthday greetings, for that
  13825.      computer-assisted personal touch.)
  13826.  
  13827.    * You can calculate age in relation to dates other than the current
  13828.      date.  For example, if you store death date in the database, you
  13829.      can easily calculate how old a pet was when it died.
  13830.  
  13831. You can probably think of other types of information that would be
  13832. useful in the `pet' table, but the ones identified so far are
  13833. sufficient for now: name, owner, species, sex, birth, and death.
  13834.  
  13835. Use a `CREATE TABLE' statement to specify the layout of your table:
  13836.  
  13837.      mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
  13838.          -> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
  13839.  
  13840. `VARCHAR' is a good choice for the `name', `owner', and `species'
  13841. columns because the column values will vary in length.  The lengths of
  13842. those columns need not all be the same, and need not be `20'.  You can
  13843. pick any length from `1' to `255', whatever seems most reasonable to
  13844. you.  (If you make a poor choice and it turns out later that you need a
  13845. longer field, MySQL provides an `ALTER TABLE' statement.)
  13846.  
  13847. Several types of values can be chosen to represent sex in animal
  13848. records, such as `'m'' and `'f'', or perhaps `'male'' and `'female''.
  13849. It's simplest to use the single characters `'m'' and `'f''.
  13850.  
  13851. The use of the `DATE' data type for the `birth' and `death' columns is
  13852. a fairly obvious choice.
  13853.  
  13854. Now that you have created a table, `SHOW TABLES' should produce some
  13855. output:
  13856.  
  13857.      mysql> SHOW TABLES;
  13858.      +---------------------+
  13859.      | Tables in menagerie |
  13860.      +---------------------+
  13861.      | pet                 |
  13862.      +---------------------+
  13863.  
  13864. To verify that your table was created the way you expected, use a
  13865. `DESCRIBE' statement:
  13866.  
  13867.      mysql> DESCRIBE pet;
  13868.      +---------+-------------+------+-----+---------+-------+
  13869.      | Field   | Type        | Null | Key | Default | Extra |
  13870.      +---------+-------------+------+-----+---------+-------+
  13871.      | name    | varchar(20) | YES  |     | NULL    |       |
  13872.      | owner   | varchar(20) | YES  |     | NULL    |       |
  13873.      | species | varchar(20) | YES  |     | NULL    |       |
  13874.      | sex     | char(1)     | YES  |     | NULL    |       |
  13875.      | birth   | date        | YES  |     | NULL    |       |
  13876.      | death   | date        | YES  |     | NULL    |       |
  13877.      +---------+-------------+------+-----+---------+-------+
  13878.  
  13879. You can use `DESCRIBE' any time, for example, if you forget the names of
  13880. the columns in your table or what types they have.
  13881.  
  13882. Loading Data into a Table
  13883. -------------------------
  13884.  
  13885. After creating your table, you need to populate it.  The `LOAD DATA' and
  13886. `INSERT' statements are useful for this.
  13887.  
  13888. Suppose that your pet records can be described as shown here.  (Observe
  13889. that MySQL expects dates in `'YYYY-MM-DD'' format; this may be
  13890. different from what you are used to.)
  13891.  
  13892. *name*  *owner* *species**sex**birth*        *death*
  13893. Fluffy  Harold  cat     f    1993-02-04     
  13894. Claws   Gwen    cat     m    1994-03-17     
  13895. Buffy   Harold  dog     f    1989-05-13     
  13896. Fang    Benny   dog     m    1990-08-27     
  13897. Bowser  Diane   dog     m    1979-08-31     1995-07-29
  13898. Chirpy  Gwen    bird    f    1998-09-11     
  13899. WhistlerGwen    bird         1997-12-09     
  13900. Slim    Benny   snake   m    1996-04-29     
  13901.  
  13902. Because you are beginning with an empty table, an easy way to populate
  13903. it is to create a text file containing a row for each of your animals,
  13904. then load the contents of the file into the table with a single
  13905. statement.
  13906.  
  13907. You could create a text file `pet.txt' containing one record per line,
  13908. with values separated by tabs, and given in the order in which the
  13909. columns were listed in the `CREATE TABLE' statement.  For missing
  13910. values (such as unknown sexes or death dates for animals that are still
  13911. living), you can use `NULL' values.  To represent these in your text
  13912. file, use `\N' (backslash, capital-N).  For example, the record for
  13913. Whistler the bird would look like this (where the whitespace between
  13914. values is a single tab character):
  13915.  
  13916. *name*  *owner* *species**sex**birth*        *death*
  13917. `Whistler'`Gwen'  `bird'  `\N' `1997-12-09'   `\N'
  13918.  
  13919. To load the text file `pet.txt' into the `pet' table, use this command:
  13920.  
  13921.      mysql> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;
  13922.  
  13923. Note that if you created the file on Windows with an editor that uses
  13924. `\r\n' as a line terminator, you should use:
  13925.  
  13926.      mysql> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet
  13927.          -> LINES TERMINATED BY '\r\n';
  13928.  
  13929. You can specify the column value separator and end of line marker
  13930. explicitly in the `LOAD DATA' statement if you wish, but the defaults
  13931. are tab and linefeed.  These are sufficient for the statement to read
  13932. the file `pet.txt' properly.
  13933.  
  13934. If the statement fails, it is likely that your MySQL installation does
  13935. not have local file capability enabled by default.  See *Note `LOAD
  13936. DATA LOCAL': LOAD DATA LOCAL for information on how to change this.
  13937.  
  13938. When you want to add new records one at a time, the `INSERT' statement
  13939. is useful.  In its simplest form, you supply values for each column, in
  13940. the order in which the columns were listed in the `CREATE TABLE'
  13941. statement.  Suppose that Diane gets a new hamster named Puffball.  You
  13942. could add a new record using an `INSERT' statement like this:
  13943.  
  13944.      mysql> INSERT INTO pet
  13945.          -> VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
  13946.  
  13947. Note that string and date values are specified as quoted strings here.
  13948. Also, with `INSERT', you can insert `NULL' directly to represent a
  13949. missing value.  You do not use `\N' like you do with `LOAD DATA'.
  13950.  
  13951. From this example, you should be able to see that there would be a lot
  13952. more typing involved to load your records initially using several
  13953. `INSERT' statements rather than a single `LOAD DATA' statement.
  13954.  
  13955. Retrieving Information from a Table
  13956. -----------------------------------
  13957.  
  13958. The `SELECT' statement is used to pull information from a table.  The
  13959. general form of the statement is:
  13960.  
  13961.      SELECT what_to_select
  13962.      FROM which_table
  13963.      WHERE conditions_to_satisfy;
  13964.  
  13965. `what_to_select' indicates what you want to see.  This can be a list of
  13966. columns, or `*' to indicate "all columns." `which_table' indicates the
  13967. table from which you want to retrieve data.  The `WHERE' clause is
  13968. optional.  If it's present, `conditions_to_satisfy' specifies
  13969. conditions that rows must satisfy to qualify for retrieval.
  13970.  
  13971. Selecting All Data
  13972. ..................
  13973.  
  13974. The simplest form of `SELECT' retrieves everything from a table:
  13975.  
  13976.      mysql> SELECT * FROM pet;
  13977.      +----------+--------+---------+------+------------+------------+
  13978.      | name     | owner  | species | sex  | birth      | death      |
  13979.      +----------+--------+---------+------+------------+------------+
  13980.      | Fluffy   | Harold | cat     | f    | 1993-02-04 | NULL       |
  13981.      | Claws    | Gwen   | cat     | m    | 1994-03-17 | NULL       |
  13982.      | Buffy    | Harold | dog     | f    | 1989-05-13 | NULL       |
  13983.      | Fang     | Benny  | dog     | m    | 1990-08-27 | NULL       |
  13984.      | Bowser   | Diane  | dog     | m    | 1979-08-31 | 1995-07-29 |
  13985.      | Chirpy   | Gwen   | bird    | f    | 1998-09-11 | NULL       |
  13986.      | Whistler | Gwen   | bird    | NULL | 1997-12-09 | NULL       |
  13987.      | Slim     | Benny  | snake   | m    | 1996-04-29 | NULL       |
  13988.      | Puffball | Diane  | hamster | f    | 1999-03-30 | NULL       |
  13989.      +----------+--------+---------+------+------------+------------+
  13990.  
  13991. This form of `SELECT' is useful if you want to review your entire table,
  13992. for example, after you've just loaded it with your initial dataset.  For
  13993. example, you may happen to think that the birth date for Bowser doesn't
  13994. seem quite right.  Consulting your original pedigree papers, you find
  13995. that the correct birth year should be 1989, not 1979.
  13996.  
  13997. There are least a couple of ways to fix this:
  13998.  
  13999.    * Edit the file `pet.txt' to correct the error, then empty the table
  14000.      and reload it using `DELETE' and `LOAD DATA':
  14001.  
  14002.           mysql> DELETE FROM pet;
  14003.           mysql> LOAD DATA LOCAL INFILE 'pet.txt' INTO TABLE pet;
  14004.  
  14005.      However, if you do this, you must also re-enter the record for
  14006.      Puffball.
  14007.  
  14008.    * Fix only the erroneous record with an `UPDATE' statement:
  14009.  
  14010.           mysql> UPDATE pet SET birth = '1989-08-31' WHERE name = 'Bowser';
  14011.  
  14012.      The `UPDATE' changes only the record in question and does not
  14013.      require you to reload the table.
  14014.  
  14015. Selecting Particular Rows
  14016. .........................
  14017.  
  14018. As shown in the preceding section, it is easy to retrieve an entire
  14019. table.  Just omit the `WHERE' clause from the `SELECT' statement.  But
  14020. typically you don't want to see the entire table, particularly when it
  14021. becomes large.  Instead, you're usually more interested in answering a
  14022. particular question, in which case you specify some constraints on the
  14023. information you want.  Let's look at some selection queries in terms of
  14024. questions about your pets that they answer.
  14025.  
  14026. You can select only particular rows from your table.  For example, if
  14027. you want to verify the change that you made to Bowser's birth date,
  14028. select Bowser's record like this:
  14029.  
  14030.      mysql> SELECT * FROM pet WHERE name = 'Bowser';
  14031.      +--------+-------+---------+------+------------+------------+
  14032.      | name   | owner | species | sex  | birth      | death      |
  14033.      +--------+-------+---------+------+------------+------------+
  14034.      | Bowser | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  14035.      +--------+-------+---------+------+------------+------------+
  14036.  
  14037. The output confirms that the year is correctly recorded now as 1989,
  14038. not 1979.
  14039.  
  14040. String comparisons normally are case-insensitive, so you can specify the
  14041. name as `'bowser'', `'BOWSER'', etc.  The query result will be the same.
  14042.  
  14043. You can specify conditions on any column, not just `name'.  For example,
  14044. if you want to know which animals were born after 1998, test the `birth'
  14045. column:
  14046.  
  14047.      mysql> SELECT * FROM pet WHERE birth >= '1998-1-1';
  14048.      +----------+-------+---------+------+------------+-------+
  14049.      | name     | owner | species | sex  | birth      | death |
  14050.      +----------+-------+---------+------+------------+-------+
  14051.      | Chirpy   | Gwen  | bird    | f    | 1998-09-11 | NULL  |
  14052.      | Puffball | Diane | hamster | f    | 1999-03-30 | NULL  |
  14053.      +----------+-------+---------+------+------------+-------+
  14054.  
  14055. You can combine conditions, for example, to locate female dogs:
  14056.  
  14057.      mysql> SELECT * FROM pet WHERE species = 'dog' AND sex = 'f';
  14058.      +-------+--------+---------+------+------------+-------+
  14059.      | name  | owner  | species | sex  | birth      | death |
  14060.      +-------+--------+---------+------+------------+-------+
  14061.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  14062.      +-------+--------+---------+------+------------+-------+
  14063.  
  14064. The preceding query uses the `AND' logical operator.  There is also an
  14065. `OR' operator:
  14066.  
  14067.      mysql> SELECT * FROM pet WHERE species = 'snake' OR species = 'bird';
  14068.      +----------+-------+---------+------+------------+-------+
  14069.      | name     | owner | species | sex  | birth      | death |
  14070.      +----------+-------+---------+------+------------+-------+
  14071.      | Chirpy   | Gwen  | bird    | f    | 1998-09-11 | NULL  |
  14072.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL  |
  14073.      | Slim     | Benny | snake   | m    | 1996-04-29 | NULL  |
  14074.      +----------+-------+---------+------+------------+-------+
  14075.  
  14076. `AND' and `OR' may be intermixed, although `AND' has higher precedence
  14077. than `OR'.  If you use both operators, it's a good idea to use
  14078. parentheses to indicate explicitly how conditions should be grouped:
  14079.  
  14080.      mysql> SELECT * FROM pet WHERE (species = 'cat' AND sex = 'm')
  14081.          -> OR (species = 'dog' AND sex = 'f');
  14082.      +-------+--------+---------+------+------------+-------+
  14083.      | name  | owner  | species | sex  | birth      | death |
  14084.      +-------+--------+---------+------+------------+-------+
  14085.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  14086.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  14087.      +-------+--------+---------+------+------------+-------+
  14088.  
  14089. Selecting Particular Columns
  14090. ............................
  14091.  
  14092. If you don't want to see entire rows from your table, just name the
  14093. columns in which you're interested, separated by commas.  For example,
  14094. if you want to know when your animals were born, select the `name' and
  14095. `birth' columns:
  14096.  
  14097.      mysql> SELECT name, birth FROM pet;
  14098.      +----------+------------+
  14099.      | name     | birth      |
  14100.      +----------+------------+
  14101.      | Fluffy   | 1993-02-04 |
  14102.      | Claws    | 1994-03-17 |
  14103.      | Buffy    | 1989-05-13 |
  14104.      | Fang     | 1990-08-27 |
  14105.      | Bowser   | 1989-08-31 |
  14106.      | Chirpy   | 1998-09-11 |
  14107.      | Whistler | 1997-12-09 |
  14108.      | Slim     | 1996-04-29 |
  14109.      | Puffball | 1999-03-30 |
  14110.      +----------+------------+
  14111.  
  14112. To find out who owns pets, use this query:
  14113.  
  14114.      mysql> SELECT owner FROM pet;
  14115.      +--------+
  14116.      | owner  |
  14117.      +--------+
  14118.      | Harold |
  14119.      | Gwen   |
  14120.      | Harold |
  14121.      | Benny  |
  14122.      | Diane  |
  14123.      | Gwen   |
  14124.      | Gwen   |
  14125.      | Benny  |
  14126.      | Diane  |
  14127.      +--------+
  14128.  
  14129. However, notice that the query simply retrieves the `owner' field from
  14130. each record, and some of them appear more than once.  To minimize the
  14131. output, retrieve each unique output record just once by adding the
  14132. keyword `DISTINCT':
  14133.  
  14134.      mysql> SELECT DISTINCT owner FROM pet;
  14135.      +--------+
  14136.      | owner  |
  14137.      +--------+
  14138.      | Benny  |
  14139.      | Diane  |
  14140.      | Gwen   |
  14141.      | Harold |
  14142.      +--------+
  14143.  
  14144. You can use a `WHERE' clause to combine row selection with column
  14145. selection.  For example, to get birth dates for dogs and cats only, use
  14146. this query:
  14147.  
  14148.      mysql> SELECT name, species, birth FROM pet
  14149.          -> WHERE species = 'dog' OR species = 'cat';
  14150.      +--------+---------+------------+
  14151.      | name   | species | birth      |
  14152.      +--------+---------+------------+
  14153.      | Fluffy | cat     | 1993-02-04 |
  14154.      | Claws  | cat     | 1994-03-17 |
  14155.      | Buffy  | dog     | 1989-05-13 |
  14156.      | Fang   | dog     | 1990-08-27 |
  14157.      | Bowser | dog     | 1989-08-31 |
  14158.      +--------+---------+------------+
  14159.  
  14160. Sorting Rows
  14161. ............
  14162.  
  14163. You may have noticed in the preceding examples that the result rows are
  14164. displayed in no particular order.  It's often easier to examine query
  14165. output when the rows are sorted in some meaningful way.  To sort a
  14166. result, use an `ORDER BY' clause.
  14167.  
  14168. Here are animal birthdays, sorted by date:
  14169.  
  14170.      mysql> SELECT name, birth FROM pet ORDER BY birth;
  14171.      +----------+------------+
  14172.      | name     | birth      |
  14173.      +----------+------------+
  14174.      | Buffy    | 1989-05-13 |
  14175.      | Bowser   | 1989-08-31 |
  14176.      | Fang     | 1990-08-27 |
  14177.      | Fluffy   | 1993-02-04 |
  14178.      | Claws    | 1994-03-17 |
  14179.      | Slim     | 1996-04-29 |
  14180.      | Whistler | 1997-12-09 |
  14181.      | Chirpy   | 1998-09-11 |
  14182.      | Puffball | 1999-03-30 |
  14183.      +----------+------------+
  14184.  
  14185. On character type columns, sorting--like all other comparison
  14186. operations--is normally performed in a case-insensitive fashion.  This
  14187. means that the order will be undefined for columns that are identical
  14188. except for their case. You can force a case-sensitive sort for a column
  14189. by using the `BINARY' cast: `ORDER BY BINARY col_name'.
  14190.  
  14191. The default sort order is ascending, with smallest values first.  To
  14192. sort in reverse (descending) order, add the `DESC' keyword to the name
  14193. of the column you are sorting by:
  14194.  
  14195.      mysql> SELECT name, birth FROM pet ORDER BY birth DESC;
  14196.      +----------+------------+
  14197.      | name     | birth      |
  14198.      +----------+------------+
  14199.      | Puffball | 1999-03-30 |
  14200.      | Chirpy   | 1998-09-11 |
  14201.      | Whistler | 1997-12-09 |
  14202.      | Slim     | 1996-04-29 |
  14203.      | Claws    | 1994-03-17 |
  14204.      | Fluffy   | 1993-02-04 |
  14205.      | Fang     | 1990-08-27 |
  14206.      | Bowser   | 1989-08-31 |
  14207.      | Buffy    | 1989-05-13 |
  14208.      +----------+------------+
  14209.  
  14210. You can sort on multiple columns, and you can sort columns in different
  14211. directions.  For example, to sort by type of animal in ascending order,
  14212. then by birth date within animal type in descending order (youngest
  14213. animals first), use the following query:
  14214.  
  14215.      mysql> SELECT name, species, birth FROM pet
  14216.          -> ORDER BY species, birth DESC;
  14217.      +----------+---------+------------+
  14218.      | name     | species | birth      |
  14219.      +----------+---------+------------+
  14220.      | Chirpy   | bird    | 1998-09-11 |
  14221.      | Whistler | bird    | 1997-12-09 |
  14222.      | Claws    | cat     | 1994-03-17 |
  14223.      | Fluffy   | cat     | 1993-02-04 |
  14224.      | Fang     | dog     | 1990-08-27 |
  14225.      | Bowser   | dog     | 1989-08-31 |
  14226.      | Buffy    | dog     | 1989-05-13 |
  14227.      | Puffball | hamster | 1999-03-30 |
  14228.      | Slim     | snake   | 1996-04-29 |
  14229.      +----------+---------+------------+
  14230.  
  14231. Note that the `DESC' keyword applies only to the column name immediately
  14232. preceding it (`birth'); it does not affect the `species' column sort
  14233. order.
  14234.  
  14235. Date Calculations
  14236. .................
  14237.  
  14238. MySQL provides several functions that you can use to perform
  14239. calculations on dates, for example, to calculate ages or extract parts
  14240. of dates.
  14241.  
  14242. To determine how many years old each of your pets is, compute the
  14243. difference in the year part of the current date and the birth date, then
  14244. subtract one if the current date occurs earlier in the calendar year
  14245. than the birth date.  The following query shows, for each pet, the
  14246. birth date, the current date, and the age in years.
  14247.  
  14248.      mysql> SELECT name, birth, CURDATE(),
  14249.          -> (YEAR(CURDATE())-YEAR(birth))
  14250.          -> - (RIGHT(CURDATE(),5)<RIGHT(birth,5))
  14251.          -> AS age
  14252.          -> FROM pet;
  14253.      +----------+------------+------------+------+
  14254.      | name     | birth      | CURDATE()  | age  |
  14255.      +----------+------------+------------+------+
  14256.      | Fluffy   | 1993-02-04 | 2003-08-19 |   10 |
  14257.      | Claws    | 1994-03-17 | 2003-08-19 |    9 |
  14258.      | Buffy    | 1989-05-13 | 2003-08-19 |   14 |
  14259.      | Fang     | 1990-08-27 | 2003-08-19 |   12 |
  14260.      | Bowser   | 1989-08-31 | 2003-08-19 |   13 |
  14261.      | Chirpy   | 1998-09-11 | 2003-08-19 |    4 |
  14262.      | Whistler | 1997-12-09 | 2003-08-19 |    5 |
  14263.      | Slim     | 1996-04-29 | 2003-08-19 |    7 |
  14264.      | Puffball | 1999-03-30 | 2003-08-19 |    4 |
  14265.      +----------+------------+------------+------+
  14266.  
  14267. Here, `YEAR()' pulls out the year part of a date and `RIGHT()' pulls
  14268. off the rightmost five characters that represent the `MM-DD' (calendar
  14269. year) part of the date.  The part of the expression that compares the
  14270. `MM-DD' values evaluates to 1 or 0, which adjusts the year difference
  14271. down a year if `CURDATE()' occurs earlier in the year than `birth'.
  14272. The full expression is somewhat ungainly, so an alias (`age') is used
  14273. to make the output column label more meaningful.
  14274.  
  14275. The query works, but the result could be scanned more easily if the rows
  14276. were presented in some order.  This can be done by adding an `ORDER BY
  14277. name' clause to sort the output by name:
  14278.  
  14279.      mysql> SELECT name, birth, CURDATE(),
  14280.          -> (YEAR(CURDATE())-YEAR(birth))
  14281.          -> - (RIGHT(CURDATE(),5)<RIGHT(birth,5))
  14282.          -> AS age
  14283.          -> FROM pet ORDER BY name;
  14284.      +----------+------------+------------+------+
  14285.      | name     | birth      | CURDATE()  | age  |
  14286.      +----------+------------+------------+------+
  14287.      | Bowser   | 1989-08-31 | 2003-08-19 |   13 |
  14288.      | Buffy    | 1989-05-13 | 2003-08-19 |   14 |
  14289.      | Chirpy   | 1998-09-11 | 2003-08-19 |    4 |
  14290.      | Claws    | 1994-03-17 | 2003-08-19 |    9 |
  14291.      | Fang     | 1990-08-27 | 2003-08-19 |   12 |
  14292.      | Fluffy   | 1993-02-04 | 2003-08-19 |   10 |
  14293.      | Puffball | 1999-03-30 | 2003-08-19 |    4 |
  14294.      | Slim     | 1996-04-29 | 2003-08-19 |    7 |
  14295.      | Whistler | 1997-12-09 | 2003-08-19 |    5 |
  14296.      +----------+------------+------------+------+
  14297.  
  14298. To sort the output by `age' rather than `name', just use a different
  14299. `ORDER BY' clause:
  14300.  
  14301.      mysql> SELECT name, birth, CURDATE(),
  14302.          -> (YEAR(CURDATE())-YEAR(birth))
  14303.          -> - (RIGHT(CURDATE(),5)<RIGHT(birth,5))
  14304.          -> AS age
  14305.          -> FROM pet ORDER BY age;
  14306.      +----------+------------+------------+------+
  14307.      | name     | birth      | CURDATE()  | age  |
  14308.      +----------+------------+------------+------+
  14309.      | Chirpy   | 1998-09-11 | 2003-08-19 |    4 |
  14310.      | Puffball | 1999-03-30 | 2003-08-19 |    4 |
  14311.      | Whistler | 1997-12-09 | 2003-08-19 |    5 |
  14312.      | Slim     | 1996-04-29 | 2003-08-19 |    7 |
  14313.      | Claws    | 1994-03-17 | 2003-08-19 |    9 |
  14314.      | Fluffy   | 1993-02-04 | 2003-08-19 |   10 |
  14315.      | Fang     | 1990-08-27 | 2003-08-19 |   12 |
  14316.      | Bowser   | 1989-08-31 | 2003-08-19 |   13 |
  14317.      | Buffy    | 1989-05-13 | 2003-08-19 |   14 |
  14318.      +----------+------------+------------+------+
  14319.  
  14320. A similar query can be used to determine age at death for animals that
  14321. have died.  You determine which animals these are by checking whether
  14322. the `death' value is `NULL'.  Then, for those with non-`NULL' values,
  14323. compute the difference between the `death' and `birth' values:
  14324.  
  14325.      mysql> SELECT name, birth, death,
  14326.          -> (YEAR(death)-YEAR(birth)) - (RIGHT(death,5)<RIGHT(birth,5))
  14327.          -> AS age
  14328.          -> FROM pet WHERE death IS NOT NULL ORDER BY age;
  14329.      +--------+------------+------------+------+
  14330.      | name   | birth      | death      | age  |
  14331.      +--------+------------+------------+------+
  14332.      | Bowser | 1989-08-31 | 1995-07-29 |    5 |
  14333.      +--------+------------+------------+------+
  14334.  
  14335. The query uses `death IS NOT NULL' rather than `death <> NULL' because
  14336. `NULL' is a special value that cannot be compared using the usual
  14337. comparison operators.  This is discussed later.  *Note Working with
  14338. `NULL': Working with NULL.
  14339.  
  14340. What if you want to know which animals have birthdays next month?  For
  14341. this type of calculation, year and day are irrelevant; you simply want
  14342. to extract the month part of the `birth' column.  MySQL provides several
  14343. date-part extraction functions, such as `YEAR()', `MONTH()', and
  14344. `DAYOFMONTH()'.  `MONTH()' is the appropriate function here.  To see
  14345. how it works, run a simple query that displays the value of both
  14346. `birth' and `MONTH(birth)':
  14347.  
  14348.      mysql> SELECT name, birth, MONTH(birth) FROM pet;
  14349.      +----------+------------+--------------+
  14350.      | name     | birth      | MONTH(birth) |
  14351.      +----------+------------+--------------+
  14352.      | Fluffy   | 1993-02-04 |            2 |
  14353.      | Claws    | 1994-03-17 |            3 |
  14354.      | Buffy    | 1989-05-13 |            5 |
  14355.      | Fang     | 1990-08-27 |            8 |
  14356.      | Bowser   | 1989-08-31 |            8 |
  14357.      | Chirpy   | 1998-09-11 |            9 |
  14358.      | Whistler | 1997-12-09 |           12 |
  14359.      | Slim     | 1996-04-29 |            4 |
  14360.      | Puffball | 1999-03-30 |            3 |
  14361.      +----------+------------+--------------+
  14362.  
  14363. Finding animals with birthdays in the upcoming month is easy, too.
  14364. Suppose that the current month is April.  Then the month value is `4'
  14365. and you look for animals born in May (month `5') like this:
  14366.  
  14367.      mysql> SELECT name, birth FROM pet WHERE MONTH(birth) = 5;
  14368.      +-------+------------+
  14369.      | name  | birth      |
  14370.      +-------+------------+
  14371.      | Buffy | 1989-05-13 |
  14372.      +-------+------------+
  14373.  
  14374. There is a small complication if the current month is December.  You
  14375. don't just add one to the month number (`12') and look for animals born
  14376. in month `13', because there is no such month.  Instead, you look for
  14377. animals born in January (month `1').
  14378.  
  14379. You can even write the query so that it works no matter what the current
  14380. month is.  That way you don't have to use a particular month number in
  14381. the query.  `DATE_ADD()' allows you to add a time interval to a given
  14382. date.  If you add a month to the value of `CURDATE()', then extract the
  14383. month part with `MONTH()', the result produces the month in which to
  14384. look for birthdays:
  14385.  
  14386.      mysql> SELECT name, birth FROM pet
  14387.          -> WHERE MONTH(birth) = MONTH(DATE_ADD(CURDATE(),INTERVAL 1 MONTH));
  14388.  
  14389. A different way to accomplish the same task is to add `1' to get the
  14390. next month after the current one (after using the modulo function
  14391. (`MOD') to wrap around the month value to `0' if it is currently `12'):
  14392.  
  14393.      mysql> SELECT name, birth FROM pet
  14394.          -> WHERE MONTH(birth) = MOD(MONTH(CURDATE()), 12) + 1;
  14395.  
  14396. Note that `MONTH' returns a number between `1' and `12'. And
  14397. `MOD(something,12)' returns a number between `0' and `11'. So the
  14398. addition has to be after the `MOD()', otherwise we would go from
  14399. November (`11') to January (`1').
  14400.  
  14401. Working with `NULL' Values
  14402. ..........................
  14403.  
  14404. The `NULL' value can be surprising until you get used to it.
  14405. Conceptually, `NULL' means missing value or unknown value and it is
  14406. treated somewhat differently than other values.  To test for `NULL',
  14407. you cannot use the arithmetic comparison operators such as `=', `<', or
  14408. `<>'.  To demonstrate this for yourself, try the following query:
  14409.  
  14410.      mysql> SELECT 1 = NULL, 1 <> NULL, 1 < NULL, 1 > NULL;
  14411.      +----------+-----------+----------+----------+
  14412.      | 1 = NULL | 1 <> NULL | 1 < NULL | 1 > NULL |
  14413.      +----------+-----------+----------+----------+
  14414.      |     NULL |      NULL |     NULL |     NULL |
  14415.      +----------+-----------+----------+----------+
  14416.  
  14417. Clearly you get no meaningful results from these comparisons.  Use the
  14418. `IS NULL' and `IS NOT NULL' operators instead:
  14419.  
  14420.      mysql> SELECT 1 IS NULL, 1 IS NOT NULL;
  14421.      +-----------+---------------+
  14422.      | 1 IS NULL | 1 IS NOT NULL |
  14423.      +-----------+---------------+
  14424.      |         0 |             1 |
  14425.      +-----------+---------------+
  14426.  
  14427. Note that in MySQL, `0' or `NULL' means false and anything else means
  14428. true. The default truth value from a boolean operation is `1'.
  14429.  
  14430. This special treatment of `NULL' is why, in the previous section, it
  14431. was necessary to determine which animals are no longer alive using
  14432. `death IS NOT NULL' instead of `death <> NULL'.
  14433.  
  14434. Two `NULL' values are regarded as equal in a `GROUP BY'.
  14435.  
  14436. When doing an `ORDER BY', `NULL' values are presented first if you do
  14437. `ORDER BY ... ASC' and last if you do `ORDER BY ... DESC'.
  14438.  
  14439. Note that MySQL 4.0.2 to 4.0.10 incorrectly always sorts `NULL' values
  14440. first regardless of the sort direction.
  14441.  
  14442. Pattern Matching
  14443. ................
  14444.  
  14445. MySQL provides standard SQL pattern matching as well as a form of
  14446. pattern matching based on extended regular expressions similar to those
  14447. used by Unix utilities such as `vi', `grep', and `sed'.
  14448.  
  14449. SQL pattern matching allows you to use `_' to match any single
  14450. character and `%' to match an arbitrary number of characters (including
  14451. zero characters).  In MySQL, SQL patterns are case-insensitive by
  14452. default.  Some examples are shown here.  Note that you do not use `='
  14453. or `<>' when you use SQL patterns; use the `LIKE' or `NOT LIKE'
  14454. comparison operators instead.
  14455.  
  14456. To find names beginning with `b':
  14457.  
  14458.      mysql> SELECT * FROM pet WHERE name LIKE 'b%';
  14459.      +--------+--------+---------+------+------------+------------+
  14460.      | name   | owner  | species | sex  | birth      | death      |
  14461.      +--------+--------+---------+------+------------+------------+
  14462.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
  14463.      | Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
  14464.      +--------+--------+---------+------+------------+------------+
  14465.  
  14466. To find names ending with `fy':
  14467.  
  14468.      mysql> SELECT * FROM pet WHERE name LIKE '%fy';
  14469.      +--------+--------+---------+------+------------+-------+
  14470.      | name   | owner  | species | sex  | birth      | death |
  14471.      +--------+--------+---------+------+------------+-------+
  14472.      | Fluffy | Harold | cat     | f    | 1993-02-04 | NULL  |
  14473.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL  |
  14474.      +--------+--------+---------+------+------------+-------+
  14475.  
  14476. To find names containing a `w':
  14477.  
  14478.      mysql> SELECT * FROM pet WHERE name LIKE '%w%';
  14479.      +----------+-------+---------+------+------------+------------+
  14480.      | name     | owner | species | sex  | birth      | death      |
  14481.      +----------+-------+---------+------+------------+------------+
  14482.      | Claws    | Gwen  | cat     | m    | 1994-03-17 | NULL       |
  14483.      | Bowser   | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  14484.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL       |
  14485.      +----------+-------+---------+------+------------+------------+
  14486.  
  14487. To find names containing exactly five characters, use five instances of
  14488. the `_' pattern character:
  14489.  
  14490.      mysql> SELECT * FROM pet WHERE name LIKE '_____';
  14491.      +-------+--------+---------+------+------------+-------+
  14492.      | name  | owner  | species | sex  | birth      | death |
  14493.      +-------+--------+---------+------+------------+-------+
  14494.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  14495.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  14496.      +-------+--------+---------+------+------------+-------+
  14497.  
  14498. The other type of pattern matching provided by MySQL uses extended
  14499. regular expressions.  When you test for a match for this type of
  14500. pattern, use the `REGEXP' and `NOT REGEXP' operators (or `RLIKE' and
  14501. `NOT RLIKE', which are synonyms).
  14502.  
  14503. Some characteristics of extended regular expressions are:
  14504.  
  14505.    * `.' matches any single character.
  14506.  
  14507.    * A character class `[...]' matches any character within the
  14508.      brackets.  For example, `[abc]' matches `a', `b', or `c'.  To name
  14509.      a range of characters, use a dash.  `[a-z]' matches any letter,
  14510.      whereas `[0-9]' matches any digit.
  14511.  
  14512.    * `*' matches zero or more instances of the thing preceding it.  For
  14513.      example, `x*' matches any number of `x' characters, `[0-9]*'
  14514.      matches any number of digits, and `.*' matches any number of
  14515.      anything.
  14516.  
  14517.    * A `REGEXP' pattern match succeed if the pattern matches anywhere
  14518.      in the value being tested.  (This differs from a `LIKE' pattern
  14519.      match, which succeeds only if the pattern matches the entire
  14520.      value.)
  14521.  
  14522.    * To anchor a pattern so that it must match the beginning or end of
  14523.      the value being tested, use `^' at the beginning or `$' at the end
  14524.      of the pattern.
  14525.  
  14526. To demonstrate how extended regular expressions work, the `LIKE' queries
  14527. shown previously are rewritten here to use `REGEXP'.
  14528.  
  14529. To find names beginning with `b', use `^' to match the beginning of the
  14530. name:
  14531.  
  14532.      mysql> SELECT * FROM pet WHERE name REGEXP '^b';
  14533.      +--------+--------+---------+------+------------+------------+
  14534.      | name   | owner  | species | sex  | birth      | death      |
  14535.      +--------+--------+---------+------+------------+------------+
  14536.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
  14537.      | Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
  14538.      +--------+--------+---------+------+------------+------------+
  14539.  
  14540. Prior to MySQL Version 3.23.4, `REGEXP' is case sensitive, and the
  14541. previous query will return no rows. In this case, to match either
  14542. lowercase or uppercase `b', use this query instead:
  14543.  
  14544.      mysql> SELECT * FROM pet WHERE name REGEXP '^[bB]';
  14545.  
  14546. From MySQL 3.23.4 on, if you really want to force a `REGEXP' comparison
  14547. to be case sensitive, use the `BINARY' keyword to make one of the
  14548. strings a binary string. This query will match only lowercase `b' at
  14549. the beginning of a name:
  14550.  
  14551.      mysql> SELECT * FROM pet WHERE name REGEXP BINARY '^b';
  14552.  
  14553. To find names ending with `fy', use `$' to match the end of the name:
  14554.  
  14555.      mysql> SELECT * FROM pet WHERE name REGEXP 'fy$';
  14556.      +--------+--------+---------+------+------------+-------+
  14557.      | name   | owner  | species | sex  | birth      | death |
  14558.      +--------+--------+---------+------+------------+-------+
  14559.      | Fluffy | Harold | cat     | f    | 1993-02-04 | NULL  |
  14560.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL  |
  14561.      +--------+--------+---------+------+------------+-------+
  14562.  
  14563. To find names containing a `w', use this query:
  14564.  
  14565.      mysql> SELECT * FROM pet WHERE name REGEXP 'w';
  14566.      +----------+-------+---------+------+------------+------------+
  14567.      | name     | owner | species | sex  | birth      | death      |
  14568.      +----------+-------+---------+------+------------+------------+
  14569.      | Claws    | Gwen  | cat     | m    | 1994-03-17 | NULL       |
  14570.      | Bowser   | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  14571.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL       |
  14572.      +----------+-------+---------+------+------------+------------+
  14573.  
  14574. Because a regular expression pattern matches if it occurs anywhere in
  14575. the value, it is not necessary in the previous query to put a wildcard
  14576. on either side of the pattern to get it to match the entire value like
  14577. it would be if you used an SQL pattern.
  14578.  
  14579. To find names containing exactly five characters, use `^' and `$' to
  14580. match the beginning and end of the name, and five instances of `.' in
  14581. between:
  14582.  
  14583.      mysql> SELECT * FROM pet WHERE name REGEXP '^.....$';
  14584.      +-------+--------+---------+------+------------+-------+
  14585.      | name  | owner  | species | sex  | birth      | death |
  14586.      +-------+--------+---------+------+------------+-------+
  14587.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  14588.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  14589.      +-------+--------+---------+------+------------+-------+
  14590.  
  14591. You could also write the previous query using the `{n}'
  14592. "repeat-`n'-times" operator:
  14593.  
  14594.      mysql> SELECT * FROM pet WHERE name REGEXP '^.{5}$';
  14595.      +-------+--------+---------+------+------------+-------+
  14596.      | name  | owner  | species | sex  | birth      | death |
  14597.      +-------+--------+---------+------+------------+-------+
  14598.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  14599.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  14600.      +-------+--------+---------+------+------------+-------+
  14601.  
  14602. Counting Rows
  14603. .............
  14604.  
  14605. Databases are often used to answer the question, "How often does a
  14606. certain type of data occur in a table?"  For example, you might want to
  14607. know how many pets you have, or how many pets each owner has, or you
  14608. might want to perform various kinds of census operations on your
  14609. animals.
  14610.  
  14611. Counting the total number of animals you have is the same question as
  14612. "How many rows are in the `pet' table?" because there is one record per
  14613. pet.  `COUNT(*)' counts the number of rows, so the query to count your
  14614. animals looks like this:
  14615.  
  14616.      mysql> SELECT COUNT(*) FROM pet;
  14617.      +----------+
  14618.      | COUNT(*) |
  14619.      +----------+
  14620.      |        9 |
  14621.      +----------+
  14622.  
  14623. Earlier, you retrieved the names of the people who owned pets.  You can
  14624. use `COUNT()' if you want to find out how many pets each owner has:
  14625.  
  14626.      mysql> SELECT owner, COUNT(*) FROM pet GROUP BY owner;
  14627.      +--------+----------+
  14628.      | owner  | COUNT(*) |
  14629.      +--------+----------+
  14630.      | Benny  |        2 |
  14631.      | Diane  |        2 |
  14632.      | Gwen   |        3 |
  14633.      | Harold |        2 |
  14634.      +--------+----------+
  14635.  
  14636. Note the use of `GROUP BY' to group together all records for each
  14637. `owner'.  Without it, all you get is an error message:
  14638.  
  14639.      mysql> SELECT owner, COUNT(*) FROM pet;
  14640.      ERROR 1140: Mixing of GROUP columns (MIN(),MAX(),COUNT()...)
  14641.      with no GROUP columns is illegal if there is no GROUP BY clause
  14642.  
  14643. `COUNT()' and `GROUP BY' are useful for characterizing your data in
  14644. various ways.  The following examples show different ways to perform
  14645. animal census operations.
  14646.  
  14647. Number of animals per species:
  14648.  
  14649.      mysql> SELECT species, COUNT(*) FROM pet GROUP BY species;
  14650.      +---------+----------+
  14651.      | species | COUNT(*) |
  14652.      +---------+----------+
  14653.      | bird    |        2 |
  14654.      | cat     |        2 |
  14655.      | dog     |        3 |
  14656.      | hamster |        1 |
  14657.      | snake   |        1 |
  14658.      +---------+----------+
  14659.  
  14660. Number of animals per sex:
  14661.  
  14662.      mysql> SELECT sex, COUNT(*) FROM pet GROUP BY sex;
  14663.      +------+----------+
  14664.      | sex  | COUNT(*) |
  14665.      +------+----------+
  14666.      | NULL |        1 |
  14667.      | f    |        4 |
  14668.      | m    |        4 |
  14669.      +------+----------+
  14670.  
  14671. (In this output, `NULL' indicates that the sex is unknown.)
  14672.  
  14673. Number of animals per combination of species and sex:
  14674.  
  14675.      mysql> SELECT species, sex, COUNT(*) FROM pet GROUP BY species, sex;
  14676.      +---------+------+----------+
  14677.      | species | sex  | COUNT(*) |
  14678.      +---------+------+----------+
  14679.      | bird    | NULL |        1 |
  14680.      | bird    | f    |        1 |
  14681.      | cat     | f    |        1 |
  14682.      | cat     | m    |        1 |
  14683.      | dog     | f    |        1 |
  14684.      | dog     | m    |        2 |
  14685.      | hamster | f    |        1 |
  14686.      | snake   | m    |        1 |
  14687.      +---------+------+----------+
  14688.  
  14689. You need not retrieve an entire table when you use `COUNT()'.  For
  14690. example, the previous query, when performed just on dogs and cats,
  14691. looks like this:
  14692.  
  14693.      mysql> SELECT species, sex, COUNT(*) FROM pet
  14694.          -> WHERE species = 'dog' OR species = 'cat'
  14695.          -> GROUP BY species, sex;
  14696.      +---------+------+----------+
  14697.      | species | sex  | COUNT(*) |
  14698.      +---------+------+----------+
  14699.      | cat     | f    |        1 |
  14700.      | cat     | m    |        1 |
  14701.      | dog     | f    |        1 |
  14702.      | dog     | m    |        2 |
  14703.      +---------+------+----------+
  14704.  
  14705. Or, if you wanted the number of animals per sex only for known-sex
  14706. animals:
  14707.  
  14708.      mysql> SELECT species, sex, COUNT(*) FROM pet
  14709.          -> WHERE sex IS NOT NULL
  14710.          -> GROUP BY species, sex;
  14711.      +---------+------+----------+
  14712.      | species | sex  | COUNT(*) |
  14713.      +---------+------+----------+
  14714.      | bird    | f    |        1 |
  14715.      | cat     | f    |        1 |
  14716.      | cat     | m    |        1 |
  14717.      | dog     | f    |        1 |
  14718.      | dog     | m    |        2 |
  14719.      | hamster | f    |        1 |
  14720.      | snake   | m    |        1 |
  14721.      +---------+------+----------+
  14722.  
  14723. Using More Than one Table
  14724. .........................
  14725.  
  14726. The `pet' table keeps track of which pets you have.  If you want to
  14727. record other information about them, such as events in their lives like
  14728. visits to the vet or when litters are born, you need another table.
  14729. What should this table look like? It needs:
  14730.  
  14731.    * To contain the pet name so you know which animal each event
  14732.      pertains to.
  14733.  
  14734.    * A date so you know when the event occurred.
  14735.  
  14736.    * A field to describe the event.
  14737.  
  14738.    * An event type field, if you want to be able to categorize events.
  14739.  
  14740. Given these considerations, the `CREATE TABLE' statement for the
  14741. `event' table might look like this:
  14742.  
  14743.      mysql> CREATE TABLE event (name VARCHAR(20), date DATE,
  14744.          -> type VARCHAR(15), remark VARCHAR(255));
  14745.  
  14746. As with the `pet' table, it's easiest to load the initial records by
  14747. creating a tab-delimited text file containing the information:
  14748.  
  14749. *name*      *date*      *type*      *remark*
  14750. Fluffy      1995-05-15  litter      4 kittens, 3 female, 1
  14751.                                     male
  14752. Buffy       1993-06-23  litter      5 puppies, 2 female, 3
  14753.                                     male
  14754. Buffy       1994-06-19  litter      3 puppies, 3 female
  14755. Chirpy      1999-03-21  vet         needed beak straightened
  14756. Slim        1997-08-03  vet         broken rib
  14757. Bowser      1991-10-12  kennel      
  14758. Fang        1991-10-12  kennel      
  14759. Fang        1998-08-28  birthday    Gave him a new chew toy
  14760. Claws       1998-03-17  birthday    Gave him a new flea
  14761.                                     collar
  14762. Whistler    1998-12-09  birthday    First birthday
  14763.  
  14764. Load the records like this:
  14765.  
  14766.      mysql> LOAD DATA LOCAL INFILE 'event.txt' INTO TABLE event;
  14767.  
  14768. Based on what you've learned from the queries you've run on the `pet'
  14769. table, you should be able to perform retrievals on the records in the
  14770. `event' table; the principles are the same.  But when is the `event'
  14771. table by itself insufficient to answer questions you might ask?
  14772.  
  14773. Suppose that you want to find out the ages at which each pet had its
  14774. litters. We saw earlier how to calculate ages from two dates.  The
  14775. litter date of the mother is in the `event' table, but to calculate her
  14776. age on that date you need her birth date, which is stored in the `pet'
  14777. table.  This means the query requires both tables:
  14778.  
  14779.      mysql> SELECT pet.name,
  14780.          -> (YEAR(date)-YEAR(birth)) - (RIGHT(date,5)<RIGHT(birth,5)) AS age,
  14781.          -> remark
  14782.          -> FROM pet, event
  14783.          -> WHERE pet.name = event.name AND type = 'litter';
  14784.      +--------+------+-----------------------------+
  14785.      | name   | age  | remark                      |
  14786.      +--------+------+-----------------------------+
  14787.      | Fluffy |    2 | 4 kittens, 3 female, 1 male |
  14788.      | Buffy  |    4 | 5 puppies, 2 female, 3 male |
  14789.      | Buffy  |    5 | 3 puppies, 3 female         |
  14790.      +--------+------+-----------------------------+
  14791.  
  14792. There are several things to note about this query:
  14793.  
  14794.    * The `FROM' clause lists two tables because the query needs to pull
  14795.      information from both of them.
  14796.  
  14797.    * When combining (joining) information from multiple tables, you
  14798.      need to specify how records in one table can be matched to records
  14799.      in the other.  This is easy because they both have a `name'
  14800.      column.  The query uses `WHERE' clause to match up records in the
  14801.      two tables based on the `name' values.
  14802.  
  14803.    * Because the `name' column occurs in both tables, you must be
  14804.      specific about which table you mean when referring to the column.
  14805.      This is done by prepending the table name to the column name.
  14806.  
  14807. You need not have two different tables to perform a join.  Sometimes it
  14808. is useful to join a table to itself, if you want to compare records in
  14809. a table to other records in that same table.  For example, to find
  14810. breeding pairs among your pets, you can join the `pet' table with
  14811. itself to produce candidate pairs of males and females of like species:
  14812.  
  14813.      mysql> SELECT p1.name, p1.sex, p2.name, p2.sex, p1.species
  14814.          -> FROM pet AS p1, pet AS p2
  14815.          -> WHERE p1.species = p2.species AND p1.sex = 'f' AND p2.sex = 'm';
  14816.      +--------+------+--------+------+---------+
  14817.      | name   | sex  | name   | sex  | species |
  14818.      +--------+------+--------+------+---------+
  14819.      | Fluffy | f    | Claws  | m    | cat     |
  14820.      | Buffy  | f    | Fang   | m    | dog     |
  14821.      | Buffy  | f    | Bowser | m    | dog     |
  14822.      +--------+------+--------+------+---------+
  14823.  
  14824. In this query, we specify aliases for the table name in order to refer
  14825. to the columns and keep straight which instance of the table each
  14826. column reference is associated with.
  14827.  
  14828. Getting Information About Databases and Tables
  14829. ==============================================
  14830.  
  14831. What if you forget the name of a database or table, or what the
  14832. structure of a given table is (for example, what its columns are
  14833. called)?  MySQL addresses this problem through several statements that
  14834. provide information about the databases and tables it supports.
  14835.  
  14836. You have already seen `SHOW DATABASES', which lists the databases
  14837. managed by the server.  To find out which database is currently
  14838. selected, use the `DATABASE()' function:
  14839.  
  14840.      mysql> SELECT DATABASE();
  14841.      +------------+
  14842.      | DATABASE() |
  14843.      +------------+
  14844.      | menagerie  |
  14845.      +------------+
  14846.  
  14847. If you haven't selected any database yet, the result is `NULL' (or the
  14848. empty string before MySQL 4.1.1).
  14849.  
  14850. To find out what tables the current database contains (for example, when
  14851. you're not sure about the name of a table), use this command:
  14852.  
  14853.      mysql> SHOW TABLES;
  14854.      +---------------------+
  14855.      | Tables in menagerie |
  14856.      +---------------------+
  14857.      | event               |
  14858.      | pet                 |
  14859.      +---------------------+
  14860.  
  14861. If you want to find out about the structure of a table, the `DESCRIBE'
  14862. command is useful; it displays information about each of a table's
  14863. columns:
  14864.  
  14865.      mysql> DESCRIBE pet;
  14866.      +---------+-------------+------+-----+---------+-------+
  14867.      | Field   | Type        | Null | Key | Default | Extra |
  14868.      +---------+-------------+------+-----+---------+-------+
  14869.      | name    | varchar(20) | YES  |     | NULL    |       |
  14870.      | owner   | varchar(20) | YES  |     | NULL    |       |
  14871.      | species | varchar(20) | YES  |     | NULL    |       |
  14872.      | sex     | char(1)     | YES  |     | NULL    |       |
  14873.      | birth   | date        | YES  |     | NULL    |       |
  14874.      | death   | date        | YES  |     | NULL    |       |
  14875.      +---------+-------------+------+-----+---------+-------+
  14876.  
  14877. `Field' indicates the column name, `Type' is the data type for the
  14878. column, `NULL' indicates whether the column can contain `NULL' values,
  14879. `Key' indicates whether the column is indexed, and `Default' specifies
  14880. the column's default value.
  14881.  
  14882. If you have indexes on a table, `SHOW INDEX FROM TBL_NAME' produces
  14883. information about them.
  14884.  
  14885. Using `mysql' in Batch Mode
  14886. ===========================
  14887.  
  14888. In the previous sections, you used `mysql' interactively to enter
  14889. queries and view the results.  You can also run `mysql' in batch mode.
  14890. To do this, put the commands you want to run in a file, then tell
  14891. `mysql' to read its input from the file:
  14892.  
  14893.      shell> mysql < BATCH-FILE
  14894.  
  14895. If you are running `mysql' under Windows and have some special
  14896. characters in the file that cause problems, you can do this:
  14897.  
  14898.      C:\> mysql -e "source BATCH-FILE"
  14899.  
  14900. If you need to specify connection parameters on the command line, the
  14901. command might look like this:
  14902.  
  14903.      shell> mysql -h HOST -u USER -p < BATCH-FILE
  14904.      Enter password: ********
  14905.  
  14906. When you use `mysql' this way, you are creating a script file, then
  14907. executing the script.
  14908.  
  14909. If you want the script to continue even if some of the statements in it
  14910. produce errors, you should use the `--force' command-line option.
  14911.  
  14912. Why use a script?  Here are a few reasons:
  14913.  
  14914.    * If you run a query repeatedly (say, every day or every week),
  14915.      making it a script allows you to avoid retyping it each time you
  14916.      execute it.
  14917.  
  14918.    * You can generate new queries from existing ones that are similar
  14919.      by copying and editing script files.
  14920.  
  14921.    * Batch mode can also be useful while you're developing a query,
  14922.      particularly for multiple-line commands or multiple-statement
  14923.      sequences of commands.  If you make a mistake, you don't have to
  14924.      retype everything.  Just edit your script to correct the error,
  14925.      then tell `mysql' to execute it again.
  14926.  
  14927.    * If you have a query that produces a lot of output, you can run the
  14928.      output through a pager rather than watching it scroll off the top
  14929.      of your screen:
  14930.  
  14931.           shell> mysql < BATCH-FILE | more
  14932.  
  14933.    * You can catch the output in a file for further processing:
  14934.  
  14935.           shell> mysql < BATCH-FILE > mysql.out
  14936.  
  14937.    * You can distribute your script to other people so they can run the
  14938.      commands, too.
  14939.  
  14940.    * Some situations do not allow for interactive use, for example,
  14941.      when you run a query from a `cron' job.  In this case, you must
  14942.      use batch mode.
  14943.  
  14944. The default output format is different (more concise) when you run
  14945. `mysql' in batch mode than when you use it interactively.  For example,
  14946. the output of `SELECT DISTINCT species FROM pet' looks like this when
  14947. `mysql' is run interactively:
  14948.  
  14949.      +---------+
  14950.      | species |
  14951.      +---------+
  14952.      | bird    |
  14953.      | cat     |
  14954.      | dog     |
  14955.      | hamster |
  14956.      | snake   |
  14957.      +---------+
  14958.  
  14959. In batch mode, the output looks like this instead:
  14960.  
  14961.      species
  14962.      bird
  14963.      cat
  14964.      dog
  14965.      hamster
  14966.      snake
  14967.  
  14968. If you want to get the interactive output format in batch mode, use
  14969. `mysql -t'.  To echo to the output the commands that are executed, use
  14970. `mysql -vvv'.
  14971.  
  14972. You can also use scripts from the `mysql' prompt by using the `source'
  14973. or `\.' command:
  14974.  
  14975.      mysql> source filename;
  14976.      mysql> \. filename
  14977.  
  14978. Examples of Common Queries
  14979. ==========================
  14980.  
  14981. Here are examples of how to solve some common problems with MySQL.
  14982.  
  14983. Some of the examples use the table `shop' to hold the price of each
  14984. article (item number) for certain traders (dealers).  Supposing that
  14985. each trader has a single fixed price per article, then (`article',
  14986. `dealer') is a primary key for the records.
  14987.  
  14988. Start the command-line tool `mysql' and select a database:
  14989.  
  14990.      shell> mysql your-database-name
  14991.  
  14992. (In most MySQL installations, you can use the database name `test').
  14993.  
  14994. You can create and populate the example table with these statements:
  14995.  
  14996.      mysql> CREATE TABLE shop (
  14997.          -> article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
  14998.          -> dealer  CHAR(20)                 DEFAULT ''     NOT NULL,
  14999.          -> price   DOUBLE(16,2)             DEFAULT '0.00' NOT NULL,
  15000.          -> PRIMARY KEY(article, dealer));
  15001.      mysql> INSERT INTO shop VALUES
  15002.          -> (1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),
  15003.          -> (3,'C',1.69),(3,'D',1.25),(4,'D',19.95);
  15004.  
  15005. After issuing the statements, the table should have the following
  15006. contents:
  15007.  
  15008.      mysql> SELECT * FROM shop;
  15009.      +---------+--------+-------+
  15010.      | article | dealer | price |
  15011.      +---------+--------+-------+
  15012.      |    0001 | A      |  3.45 |
  15013.      |    0001 | B      |  3.99 |
  15014.      |    0002 | A      | 10.99 |
  15015.      |    0003 | B      |  1.45 |
  15016.      |    0003 | C      |  1.69 |
  15017.      |    0003 | D      |  1.25 |
  15018.      |    0004 | D      | 19.95 |
  15019.      +---------+--------+-------+
  15020.  
  15021. The Maximum Value for a Column
  15022. ------------------------------
  15023.  
  15024. "What's the highest item number?"
  15025.  
  15026.      SELECT MAX(article) AS article FROM shop;
  15027.      
  15028.      +---------+
  15029.      | article |
  15030.      +---------+
  15031.      |       4 |
  15032.      +---------+
  15033.  
  15034. The Row Holding the Maximum of a Certain Column
  15035. -----------------------------------------------
  15036.  
  15037. "Find number, dealer, and price of the most expensive article."
  15038.  
  15039. In standard SQL (and as of MySQL 4.1), this is easily done with a
  15040. subquery:
  15041.  
  15042.      SELECT article, dealer, price
  15043.      FROM   shop
  15044.      WHERE  price=(SELECT MAX(price) FROM shop);
  15045.  
  15046. In MySQL versions prior to 4.1, just do it in two steps:
  15047.  
  15048.   1. Get the maximum price value from the table with a `SELECT'
  15049.      statement.
  15050.           mysql> SELECT MAX(price) FROM shop;
  15051.           +------------+
  15052.           | MAX(price) |
  15053.           +------------+
  15054.           |      19.95 |
  15055.           +------------+
  15056.  
  15057.   2. Using the value 19.95 shown by the previous query to be the maximum
  15058.      article price, write a query to locate and display the
  15059.      corresponding record:
  15060.           mysql> SELECT article, dealer, price
  15061.               -> FROM   shop
  15062.               -> WHERE  price=19.95;
  15063.           +---------+--------+-------+
  15064.           | article | dealer | price |
  15065.           +---------+--------+-------+
  15066.           |    0004 | D      | 19.95 |
  15067.           +---------+--------+-------+
  15068.  
  15069. Another solution is to sort all rows descending by price and only get
  15070. the first row using the MySQL-specific `LIMIT' clause:
  15071.  
  15072.      SELECT article, dealer, price
  15073.      FROM   shop
  15074.      ORDER BY price DESC
  15075.      LIMIT 1;
  15076.  
  15077. Note:  If there were several most expensive articles, each with a price
  15078. of 19.95, the `LIMIT' solution would show only one of them!
  15079.  
  15080. Maximum of Column per Group
  15081. ---------------------------
  15082.  
  15083. "What's the highest price per article?"
  15084.  
  15085.      SELECT article, MAX(price) AS price
  15086.      FROM   shop
  15087.      GROUP BY article
  15088.      
  15089.      +---------+-------+
  15090.      | article | price |
  15091.      +---------+-------+
  15092.      |    0001 |  3.99 |
  15093.      |    0002 | 10.99 |
  15094.      |    0003 |  1.69 |
  15095.      |    0004 | 19.95 |
  15096.      +---------+-------+
  15097.  
  15098. The Rows Holding the Group-wise Maximum of a Certain Field
  15099. ----------------------------------------------------------
  15100.  
  15101. "For each article, find the dealer or dealers with the most expensive
  15102. price."
  15103.  
  15104. In standard SQL (and as of MySQL 4.1), the problem can be solved with a
  15105. subquery like this:
  15106.  
  15107.      SELECT article, dealer, price
  15108.      FROM   shop s1
  15109.      WHERE  price=(SELECT MAX(s2.price)
  15110.                    FROM shop s2
  15111.                    WHERE s1.article = s2.article);
  15112.  
  15113. In MySQL versions prior to 4.1, it's best do it in several steps:
  15114.  
  15115.   1. Get the list of (article,maxprice) pairs.
  15116.  
  15117.   2. For each article, get the corresponding rows that have the stored
  15118.      maximum price.
  15119.  
  15120. This can easily be done with a temporary table and a join:
  15121.  
  15122.      CREATE TEMPORARY TABLE tmp (
  15123.              article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
  15124.              price   DOUBLE(16,2)             DEFAULT '0.00' NOT NULL);
  15125.      
  15126.      LOCK TABLES shop READ;
  15127.      
  15128.      INSERT INTO tmp SELECT article, MAX(price) FROM shop GROUP BY article;
  15129.      
  15130.      SELECT shop.article, dealer, shop.price FROM shop, tmp
  15131.      WHERE shop.article=tmp.article AND shop.price=tmp.price;
  15132.      
  15133.      UNLOCK TABLES;
  15134.      
  15135.      DROP TABLE tmp;
  15136.  
  15137. If you don't use a `TEMPORARY' table, you must also lock the `tmp'
  15138. table.
  15139.  
  15140. "Can it be done with a single query?"
  15141.  
  15142. Yes, but only by using a quite inefficient trick called the "MAX-CONCAT
  15143. trick":
  15144.  
  15145.      SELECT article,
  15146.             SUBSTRING( MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 7) AS dealer,
  15147.        0.00+LEFT(      MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 6) AS price
  15148.      FROM   shop
  15149.      GROUP BY article;
  15150.      
  15151.      +---------+--------+-------+
  15152.      | article | dealer | price |
  15153.      +---------+--------+-------+
  15154.      |    0001 | B      |  3.99 |
  15155.      |    0002 | A      | 10.99 |
  15156.      |    0003 | C      |  1.69 |
  15157.      |    0004 | D      | 19.95 |
  15158.      +---------+--------+-------+
  15159.  
  15160. The last example can be made a bit more efficient by doing the
  15161. splitting of the concatenated column in the client.
  15162.  
  15163. Using User Variables
  15164. --------------------
  15165.  
  15166. You can use MySQL user variables to remember results without having to
  15167. store them in temporary variables in the client.  *Note Variables::.
  15168.  
  15169. For example, to find the articles with the highest and lowest price you
  15170. can do this:
  15171.  
  15172.      mysql> SELECT @min_price:=MIN(price),@max_price:=MAX(price) FROM shop;
  15173.      mysql> SELECT * FROM shop WHERE price=@min_price OR price=@max_price;
  15174.      +---------+--------+-------+
  15175.      | article | dealer | price |
  15176.      +---------+--------+-------+
  15177.      |    0003 | D      |  1.25 |
  15178.      |    0004 | D      | 19.95 |
  15179.      +---------+--------+-------+
  15180.  
  15181. Using Foreign Keys
  15182. ------------------
  15183.  
  15184. In MySQL 3.23.44 and up, `InnoDB' tables support checking of foreign
  15185. key constraints. *Note `InnoDB': InnoDB.  See also *Note ANSI diff
  15186. Foreign Keys::.
  15187.  
  15188. You don't actually need foreign keys to join two tables.  For table
  15189. types other than `InnoDB', the only things MySQL currently doesn't do
  15190. are 1) `CHECK' to make sure that the keys you use really exist in the
  15191. table or tables you're referencing and 2) automatically delete rows
  15192. from a table with a foreign key definition. Using your keys to join
  15193. tables will work just fine:
  15194.  
  15195.      CREATE TABLE person (
  15196.          id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
  15197.          name CHAR(60) NOT NULL,
  15198.          PRIMARY KEY (id)
  15199.      );
  15200.      
  15201.      CREATE TABLE shirt (
  15202.          id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
  15203.          style ENUM('t-shirt', 'polo', 'dress') NOT NULL,
  15204.          color ENUM('red', 'blue', 'orange', 'white', 'black') NOT NULL,
  15205.          owner SMALLINT UNSIGNED NOT NULL REFERENCES person(id),
  15206.          PRIMARY KEY (id)
  15207.      );
  15208.      
  15209.      
  15210.      INSERT INTO person VALUES (NULL, 'Antonio Paz');
  15211.      
  15212.      INSERT INTO shirt VALUES
  15213.      (NULL, 'polo', 'blue', LAST_INSERT_ID()),
  15214.      (NULL, 'dress', 'white', LAST_INSERT_ID()),
  15215.      (NULL, 't-shirt', 'blue', LAST_INSERT_ID());
  15216.      
  15217.      
  15218.      INSERT INTO person VALUES (NULL, 'Lilliana Angelovska');
  15219.      
  15220.      INSERT INTO shirt VALUES
  15221.      (NULL, 'dress', 'orange', LAST_INSERT_ID()),
  15222.      (NULL, 'polo', 'red', LAST_INSERT_ID()),
  15223.      (NULL, 'dress', 'blue', LAST_INSERT_ID()),
  15224.      (NULL, 't-shirt', 'white', LAST_INSERT_ID());
  15225.      
  15226.      
  15227.      SELECT * FROM person;
  15228.      +----+---------------------+
  15229.      | id | name                |
  15230.      +----+---------------------+
  15231.      |  1 | Antonio Paz         |
  15232.      |  2 | Lilliana Angelovska |
  15233.      +----+---------------------+
  15234.      
  15235.      SELECT * FROM shirt;
  15236.      +----+---------+--------+-------+
  15237.      | id | style   | color  | owner |
  15238.      +----+---------+--------+-------+
  15239.      |  1 | polo    | blue   |     1 |
  15240.      |  2 | dress   | white  |     1 |
  15241.      |  3 | t-shirt | blue   |     1 |
  15242.      |  4 | dress   | orange |     2 |
  15243.      |  5 | polo    | red    |     2 |
  15244.      |  6 | dress   | blue   |     2 |
  15245.      |  7 | t-shirt | white  |     2 |
  15246.      +----+---------+--------+-------+
  15247.      
  15248.      
  15249.      SELECT s.* FROM person p, shirt s
  15250.       WHERE p.name LIKE 'Lilliana%'
  15251.         AND s.owner = p.id
  15252.         AND s.color <> 'white';
  15253.      
  15254.      +----+-------+--------+-------+
  15255.      | id | style | color  | owner |
  15256.      +----+-------+--------+-------+
  15257.      |  4 | dress | orange |     2 |
  15258.      |  5 | polo  | red    |     2 |
  15259.      |  6 | dress | blue   |     2 |
  15260.      +----+-------+--------+-------+
  15261.  
  15262. Searching on Two Keys
  15263. ---------------------
  15264.  
  15265. An `OR' using a single key is well optimized, as is the handling of
  15266. `AND'.
  15267.  
  15268. The one tricky case is that of searching on two different keys combined
  15269. with `OR':
  15270.  
  15271.      SELECT field1_index, field2_index FROM test_table
  15272.      WHERE field1_index = '1' OR  field2_index = '1'
  15273.  
  15274. This case is optimized from MySQL 5.0.0.  *Note Index Merge
  15275. optimization::.
  15276.  
  15277. In MySQL 4.0 and up, you can also solve the problem efficiently by
  15278. using a `UNION' that combines the output of two separate `SELECT'
  15279. statements.  *Note UNION::.
  15280.  
  15281. Each `SELECT' searches only one key and can be optimized:
  15282.  
  15283.      SELECT field1_index, field2_index
  15284.          FROM test_table WHERE field1_index = '1'
  15285.      UNION
  15286.      SELECT field1_index, field2_index
  15287.          FROM test_table WHERE field2_index = '1';
  15288.  
  15289. Prior to MySQL 4.0, you can achieve the same effect by using a
  15290. `TEMPORARY' table and separate `SELECT' statements.  This type of
  15291. optimization is also very good if you are using very complicated
  15292. queries where the SQL server does the optimizations in the wrong order.
  15293.  
  15294.      CREATE TEMPORARY TABLE tmp
  15295.      SELECT field1_index, field2_index
  15296.          FROM test_table WHERE field1_index = '1';
  15297.      INSERT INTO tmp
  15298.      SELECT field1_index, field2_index
  15299.          FROM test_table WHERE field2_index = '1';
  15300.      SELECT * from tmp;
  15301.      DROP TABLE tmp;
  15302.  
  15303. This method of solving the problem is in effect a `UNION' of two
  15304. queries.
  15305.  
  15306. Calculating Visits Per Day
  15307. --------------------------
  15308.  
  15309. The following example shows how you can use the bit group functions to
  15310. calculate the number of days per month a user has visited a Web page.
  15311.  
  15312.      CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL,
  15313.                   day INT(2) UNSIGNED ZEROFILL);
  15314.      INSERT INTO t1 VALUES(2000,1,1),(2000,1,20),(2000,1,30),(2000,2,2),
  15315.                  (2000,2,23),(2000,2,23);
  15316.  
  15317. The example table contains year-month-day values representing visits by
  15318. users to the page. To determine how many different days in each month
  15319. these visits occur, use this query:
  15320.  
  15321.      SELECT year,month,BIT_COUNT(BIT_OR(1<<day)) AS days FROM t1
  15322.             GROUP BY year,month;
  15323.  
  15324. Which returns:
  15325.  
  15326.      +------+-------+------+
  15327.      | year | month | days |
  15328.      +------+-------+------+
  15329.      | 2000 |    01 |    3 |
  15330.      | 2000 |    02 |    2 |
  15331.      +------+-------+------+
  15332.  
  15333. The query calculates how many different days appear in the table for
  15334. each year/month combination, with automatic removal of duplicate
  15335. entries.
  15336.  
  15337. Using `AUTO_INCREMENT'
  15338. ----------------------
  15339.  
  15340. The `AUTO_INCREMENT' attribute can be used to generate a unique
  15341. identity for new rows:
  15342.  
  15343.      CREATE TABLE animals (
  15344.                   id MEDIUMINT NOT NULL AUTO_INCREMENT,
  15345.                   name CHAR(30) NOT NULL,
  15346.                   PRIMARY KEY (id)
  15347.                   );
  15348.      INSERT INTO animals (name) VALUES ('dog'),('cat'),('penguin'),
  15349.                                        ('lax'),('whale'),('ostrich');
  15350.      SELECT * FROM animals;
  15351.  
  15352. Which returns:
  15353.  
  15354.      +----+---------+
  15355.      | id | name    |
  15356.      +----+---------+
  15357.      |  1 | dog     |
  15358.      |  2 | cat     |
  15359.      |  3 | penguin |
  15360.      |  4 | lax     |
  15361.      |  5 | whale   |
  15362.      |  6 | ostrich |
  15363.      +----+---------+
  15364.  
  15365. You can retrieve the most recent `AUTO_INCREMENT' value with the
  15366. `LAST_INSERT_ID()' SQL function or the `mysql_insert_id()' C API
  15367. function. These functions are connection-specific, so their return value
  15368. is not affected by another connection also doing inserts.
  15369.  
  15370. Note: For a multiple-row insert, `LAST_INSERT_ID()'/`mysql_insert_id()'
  15371. will actually return the `AUTO_INCREMENT' key from the *first* of the
  15372. inserted rows.  This allows multiple-row inserts to be reproduced
  15373. correctly on other servers in a replication setup.
  15374.  
  15375. For `MyISAM' and `BDB' tables you can specify `AUTO_INCREMENT' on a
  15376. secondary column in a multiple-column index.  In this case, the
  15377. generated value for the `AUTO_INCREMENT' column is calculated as
  15378. `MAX(auto_increment_column)+1 WHERE prefix=given-prefix'.  This is
  15379. useful when you want to put data into ordered groups.
  15380.  
  15381.      CREATE TABLE animals (
  15382.                   grp ENUM('fish','mammal','bird') NOT NULL,
  15383.                   id MEDIUMINT NOT NULL AUTO_INCREMENT,
  15384.                   name CHAR(30) NOT NULL,
  15385.                   PRIMARY KEY (grp,id)
  15386.                   );
  15387.      INSERT INTO animals (grp,name) VALUES('mammal','dog'),('mammal','cat'),
  15388.                        ('bird','penguin'),('fish','lax'),('mammal','whale'),
  15389.                        ('bird','ostrich');
  15390.      SELECT * FROM animals ORDER BY grp,id;
  15391.  
  15392. Which returns:
  15393.  
  15394.      +--------+----+---------+
  15395.      | grp    | id | name    |
  15396.      +--------+----+---------+
  15397.      | fish   |  1 | lax     |
  15398.      | mammal |  1 | dog     |
  15399.      | mammal |  2 | cat     |
  15400.      | mammal |  3 | whale   |
  15401.      | bird   |  1 | penguin |
  15402.      | bird   |  2 | ostrich |
  15403.      +--------+----+---------+
  15404.  
  15405. Note that in this case (when the `AUTO_INCREMENT' column is part of a
  15406. multiple-column index), `AUTO_INCREMENT' values will be reused if you
  15407. delete the row with the biggest `AUTO_INCREMENT' value in any group.
  15408. This happens even for `MyISAM' tables, for which `AUTO_INCREMENT'
  15409. values normally are not reused.)
  15410.  
  15411. Queries from the Twin Project
  15412. =============================
  15413.  
  15414. At Analytikerna and Lentus, we have been doing the systems and field
  15415. work for a big research project. This project is a collaboration
  15416. between the Institute of Environmental Medicine at Karolinska
  15417. Institutet Stockholm and the Section on Clinical Research in Aging and
  15418. Psychology at the University of Southern California.
  15419.  
  15420. The project involves a screening part where all twins in Sweden older
  15421. than 65 years are interviewed by telephone. Twins who meet certain
  15422. criteria are passed on to the next stage. In this latter stage, twins
  15423. who want to participate are visited by a doctor/nurse team. Some of the
  15424. examinations include physical and neuropsychological examination,
  15425. laboratory testing, neuroimaging, psychological status assessment, and
  15426. family history collection. In addition, data are collected on medical
  15427. and environmental risk factors.
  15428.  
  15429. More information about Twin studies can be found at:
  15430. `http://www.mep.ki.se/twinreg/index_en.html'
  15431.  
  15432. The latter part of the project is administered with a Web interface
  15433. written using Perl and MySQL.
  15434.  
  15435. Each night all data from the interviews is moved into a MySQL database.
  15436.  
  15437. Find All Non-distributed Twins
  15438. ------------------------------
  15439.  
  15440. The following query is used to determine who goes into the second part
  15441. of the project:
  15442.  
  15443.      SELECT
  15444.          CONCAT(p1.id, p1.tvab) + 0 AS tvid,
  15445.          CONCAT(p1.christian_name, ' ', p1.surname) AS Name,
  15446.          p1.postal_code AS Code,
  15447.          p1.city AS City,
  15448.          pg.abrev AS Area,
  15449.          IF(td.participation = 'Aborted', 'A', ' ') AS A,
  15450.          p1.dead AS dead1,
  15451.          l.event AS event1,
  15452.          td.suspect AS tsuspect1,
  15453.          id.suspect AS isuspect1,
  15454.          td.severe AS tsevere1,
  15455.          id.severe AS isevere1,
  15456.          p2.dead AS dead2,
  15457.          l2.event AS event2,
  15458.          h2.nurse AS nurse2,
  15459.          h2.doctor AS doctor2,
  15460.          td2.suspect AS tsuspect2,
  15461.          id2.suspect AS isuspect2,
  15462.          td2.severe AS tsevere2,
  15463.          id2.severe AS isevere2,
  15464.          l.finish_date
  15465.      FROM
  15466.          twin_project AS tp
  15467.          /* For Twin 1 */
  15468.          LEFT JOIN twin_data AS td ON tp.id = td.id
  15469.                    AND tp.tvab = td.tvab
  15470.          LEFT JOIN informant_data AS id ON tp.id = id.id
  15471.                    AND tp.tvab = id.tvab
  15472.          LEFT JOIN harmony AS h ON tp.id = h.id
  15473.                    AND tp.tvab = h.tvab
  15474.          LEFT JOIN lentus AS l ON tp.id = l.id
  15475.                    AND tp.tvab = l.tvab
  15476.          /* For Twin 2 */
  15477.          LEFT JOIN twin_data AS td2 ON p2.id = td2.id
  15478.                    AND p2.tvab = td2.tvab
  15479.          LEFT JOIN informant_data AS id2 ON p2.id = id2.id
  15480.                    AND p2.tvab = id2.tvab
  15481.          LEFT JOIN harmony AS h2 ON p2.id = h2.id
  15482.                    AND p2.tvab = h2.tvab
  15483.          LEFT JOIN lentus AS l2 ON p2.id = l2.id
  15484.                    AND p2.tvab = l2.tvab,
  15485.          person_data AS p1,
  15486.          person_data AS p2,
  15487.          postal_groups AS pg
  15488.      WHERE
  15489.          /* p1 gets main twin and p2 gets his/her twin. */
  15490.          /* ptvab is a field inverted from tvab */
  15491.          p1.id = tp.id AND p1.tvab = tp.tvab AND
  15492.          p2.id = p1.id AND p2.ptvab = p1.tvab AND
  15493.          /* Just the sceening survey */
  15494.          tp.survey_no = 5 AND
  15495.          /* Skip if partner died before 65 but allow emigration (dead=9) */
  15496.          (p2.dead = 0 OR p2.dead = 9 OR
  15497.           (p2.dead = 1 AND
  15498.            (p2.death_date = 0 OR
  15499.             (((TO_DAYS(p2.death_date) - TO_DAYS(p2.birthday)) / 365)
  15500.              >= 65))))
  15501.          AND
  15502.          (
  15503.          /* Twin is suspect */
  15504.          (td.future_contact = 'Yes' AND td.suspect = 2) OR
  15505.          /* Twin is suspect - Informant is Blessed */
  15506.          (td.future_contact = 'Yes' AND td.suspect = 1
  15507.                                     AND id.suspect = 1) OR
  15508.          /* No twin - Informant is Blessed */
  15509.          (ISNULL(td.suspect) AND id.suspect = 1
  15510.                              AND id.future_contact = 'Yes') OR
  15511.          /* Twin broken off - Informant is Blessed */
  15512.          (td.participation = 'Aborted'
  15513.           AND id.suspect = 1 AND id.future_contact = 'Yes') OR
  15514.          /* Twin broken off - No inform - Have partner */
  15515.          (td.participation = 'Aborted' AND ISNULL(id.suspect)
  15516.                                        AND p2.dead = 0))
  15517.          AND
  15518.          l.event = 'Finished'
  15519.          /* Get at area code */
  15520.          AND SUBSTRING(p1.postal_code, 1, 2) = pg.code
  15521.          /* Not already distributed */
  15522.          AND (h.nurse IS NULL OR h.nurse=00 OR h.doctor=00)
  15523.          /* Has not refused or been aborted */
  15524.          AND NOT (h.status = 'Refused' OR h.status = 'Aborted'
  15525.          OR h.status = 'Died' OR h.status = 'Other')
  15526.      ORDER BY
  15527.          tvid;
  15528.  
  15529. Some explanations:
  15530. `CONCAT(p1.id, p1.tvab) + 0 AS tvid'
  15531.      We want to sort on the concatenated `id' and `tvab' in numerical
  15532.      order. Adding `0' to the result causes MySQL to treat the result
  15533.      as a number.
  15534.  
  15535. column `id'
  15536.      This identifies a pair of twins. It is a key in all tables.
  15537.  
  15538. column `tvab'
  15539.      This identifies a twin in a pair. It has a value of `1' or `2'.
  15540.  
  15541. column `ptvab'
  15542.      This is an inverse of `tvab'. When `tvab' is `1' this is `2', and
  15543.      vice versa. It exists to save typing and to make it easier for
  15544.      MySQL to optimize the query.
  15545.  
  15546. This query demonstrates, among other things, how to do lookups on a
  15547. table from the same table with a join (`p1' and `p2'). In the example,
  15548. this is used to check whether a twin's partner died before the age of
  15549. 65. If so, the row is not returned.
  15550.  
  15551. All of the above exist in all tables with twin-related information. We
  15552. have a key on both `id,tvab' (all tables), and `id,ptvab'
  15553. (`person_data') to make queries faster.
  15554.  
  15555. On our production machine (A 200MHz UltraSPARC), this query returns
  15556. about 150-200 rows and takes less than one second.
  15557.  
  15558. The current number of records in the tables used in the query:
  15559. *Table*            *Rows*
  15560. `person_data'      71074
  15561. `lentus'           5291
  15562. `twin_project'     5286
  15563. `twin_data'        2012
  15564. `informant_data'   663
  15565. `harmony'          381
  15566. `postal_groups'    100
  15567.  
  15568. Show a Table of Twin Pair Status
  15569. --------------------------------
  15570.  
  15571. Each interview ends with a status code called `event'. The query shown
  15572. here is used to display a table over all twin pairs combined by event.
  15573. This indicates in how many pairs both twins are finished, in how many
  15574. pairs one twin is finished and the other refused, and so on.
  15575.  
  15576.      SELECT
  15577.              t1.event,
  15578.              t2.event,
  15579.              COUNT(*)
  15580.      FROM
  15581.              lentus AS t1,
  15582.              lentus AS t2,
  15583.              twin_project AS tp
  15584.      WHERE
  15585.              /* We are looking at one pair at a time */
  15586.              t1.id = tp.id
  15587.              AND t1.tvab=tp.tvab
  15588.              AND t1.id = t2.id
  15589.              /* Just the sceening survey */
  15590.              AND tp.survey_no = 5
  15591.              /* This makes each pair only appear once */
  15592.              AND t1.tvab='1' AND t2.tvab='2'
  15593.      GROUP BY
  15594.              t1.event, t2.event;
  15595.  
  15596. Using MySQL with Apache
  15597. =======================
  15598.  
  15599. There are programs that let you authenticate your users from a MySQL
  15600. database and also let you write your log files into a MySQL table.
  15601.  
  15602. You can change the Apache logging format to be easily readable by MySQL
  15603. by putting the following into the Apache configuration file:
  15604.  
  15605.      LogFormat \
  15606.              "\"%h\",%{%Y%m%d%H%M%S}t,%>s,\"%b\",\"%{Content-Type}o\",  \
  15607.              \"%U\",\"%{Referer}i\",\"%{User-Agent}i\""
  15608.  
  15609. To load a log file in that format into MySQL, you can use a statement
  15610. something like this:
  15611.  
  15612.      LOAD DATA INFILE '/LOCAL/ACCESS_LOG' INTO TABLE TBL_NAME
  15613.      FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
  15614.  
  15615. The named table should be created to have columns that correspond to
  15616. those that the `LogFormat' line writes to the log file.
  15617.  
  15618. Using MySQL Programs
  15619. ********************
  15620.  
  15621. This chapter provides a brief overview of the programs provided by
  15622. MySQL AB and discusses how to specify options when you run these
  15623. programs.  Most programs have options that are specific to their own
  15624. operation, but the syntax for specifying options is similar for all of
  15625. them. Later chapters provide more detailed descriptions of individual
  15626. programs, including which options they recognize.
  15627.  
  15628. Overview of MySQL Programs
  15629. ==========================
  15630.  
  15631. MySQL AB provides several types of programs:
  15632.  
  15633. The MYSQL server and server startup scripts:
  15634.         * `mysqld' is the MySQL server
  15635.  
  15636.         * `mysqld_safe', `mysql.server', and `mysqld_multi' are server
  15637.           startup scripts
  15638.  
  15639.         * `mysql_install_db' initializes the data directory and the
  15640.           initial databases
  15641.  
  15642.      These programs are discussed further in *Note MySQL Database
  15643.      Administration::.
  15644.  
  15645. Client programs that access the server:
  15646.         * `mysql' is a command-line client for executing SQL statements
  15647.           interactively or in batch mode
  15648.  
  15649.         * `mysqlcc' (MySQL Control Center) is an interactive graphical
  15650.           tool for executing SQL statements and administration
  15651.  
  15652.         * `mysqladmin' is an administrative client
  15653.  
  15654.         * `mysqlcheck' performs table maintenance operations
  15655.  
  15656.         * `mysqldump' and `mysqlhotcopy' make database backups
  15657.  
  15658.         * `mysqlimport' imports data files
  15659.  
  15660.         * `mysqlshow' displays information about databases and tables
  15661.  
  15662.      These programs are discussed further in *Note Client-Side
  15663.      Scripts::.
  15664.  
  15665. Utility programs that operate independently of the server:
  15666.         * `myisamchk' performs table maintenance operations
  15667.  
  15668.         * `myisampack' produces compressed, read-only tables
  15669.  
  15670.         * `mysqlbinlog' is a tool for processing binary log files
  15671.  
  15672.         * `perror' displays error code meanings
  15673.  
  15674.      `myisamchk' is discussed further in *Note MySQL Database
  15675.      Administration::.  The other programs are further in *Note
  15676.      Client-Side Scripts::.
  15677.  
  15678. Most MySQL distributions include all of these programs, except for those
  15679. programs that are platform-specific. (For example, the server startup
  15680. scripts are not used on Windows.) The exception is that RPM
  15681. distributions are more specialized. There is one RPM for the server,
  15682. another for the client programs, and so forth. If you appear to be
  15683. missing one or more programs, see *Note Installing:: for information on
  15684. types of distributions and what they contain.  It may be that you need
  15685. to install something else.
  15686.  
  15687. Invoking MySQL Programs
  15688. =======================
  15689.  
  15690. To invoke a MySQL program at the command line (that is, from your shell
  15691. or command prompt), enter the program name followed by any options or
  15692. other arguments needed to instruct the program what you want it to do.
  15693. The following commands show some sample program invocations. "`shell>'"
  15694. represents the prompt for your command interpreter; it is not part of
  15695. what you type.  The particular prompt you will see depends on your
  15696. command interpreter.  Typical prompts are `$' for `sh' or `bash', `%'
  15697. for `csh' or `tcsh', and `C:\>' for Windows `command.com' or `cmd.exe'.
  15698.  
  15699.      shell> mysql test
  15700.      shell> mysqladmin extended-status variables
  15701.      shell> mysqlshow --help
  15702.      shell> mysqldump --user=root personnel
  15703.  
  15704. Arguments that begin with a dash are option arguments. They typically
  15705. specify the type of connection a program should make to the server or
  15706. affect its operational mode. Options have a syntax that is described in
  15707. *Note Program Options::.
  15708.  
  15709. Non-option arguments (arguments with no leading dash) provide additional
  15710. information to the program. For example, the `mysql' program interprets
  15711. the first non-option argument as a database name, so the command `mysql
  15712. test' indicates that you want to use the `test' database.
  15713.  
  15714. Later sections that describe individual programs indicate which options
  15715. a program understands and describe the meaning of any additional
  15716. non-option arguments.
  15717.  
  15718. Some options are common to a number of programs. The most common of
  15719. these are the `--host', `--user', and `--password' options that specify
  15720. connection parameters. They indicate the host where the MySQL server is
  15721. running, and the username and password of your MySQL account. All MySQL
  15722. client programs understand these options; they allow you to specify
  15723. which server to connect to and the account to use on that server.
  15724.  
  15725. You may find it necessary to invoke MySQL programs using the pathname
  15726. to the `bin' directory in which they are installed. This is likely to
  15727. be the case if you get a "program not found" error whenever you attempt
  15728. to run a MySQL program from any directory other than the `bin'
  15729. directory.  To make it more convenient to use MySQL, you can add the
  15730. pathname of the `bin' directory to your `PATH' environment variable
  15731. setting. Then to run a program you need only type its name, not its
  15732. entire pathname.
  15733.  
  15734. Consult the documentation for your command interpreter for instructions
  15735. on setting your `PATH'. The syntax for setting environment variables is
  15736. interpreter-specific.
  15737.  
  15738. Specifying Program Options
  15739. ==========================
  15740.  
  15741. You can provide options for MySQL programs in several ways:
  15742.  
  15743.    * On the command line following the program name. This is most
  15744.      common for options that apply to a specific invocation of the
  15745.      program.
  15746.  
  15747.    * In an option file that the program reads when it starts. This is
  15748.      common for options that you want the program to use each time it
  15749.      runs.
  15750.  
  15751.    * In environment variables. These are useful for options that you
  15752.      want to apply each time the program runs, although in practice
  15753.      option files are used more commonly for this purpose.  (*Note
  15754.      Multiple Unix servers:: discusses one situation in which
  15755.      environment variables can be very helpful. It describes a handy
  15756.      technique that uses such variables to specify the TCP/IP port
  15757.      number and Unix socket file for both the server and client
  15758.      programs.)
  15759.  
  15760.  
  15761. MySQL programs determine which options are given first by examining
  15762. environment variables, then option files, and then the command line.
  15763. If an option is specified multiple times, the last occurrence takes
  15764. precedence.  This means that environment variables have the lowest
  15765. precedence and command-line options the highest.
  15766.  
  15767. You can take advantage of the way that MySQL programs process options by
  15768. specifying the default values for a program's options in an option
  15769. file. Then you need not type them each time you run the program, but
  15770. can override the defaults if necessary by using command-line options.
  15771.  
  15772. Using Options on the Command Line
  15773. ---------------------------------
  15774.  
  15775. Program options specified on the command line follow these rules:
  15776.  
  15777.    * Options are given after the command name.
  15778.  
  15779.    * An option argument begins with one dash or two dashes, depending
  15780.      on whether it has a short name or a long name. Many options have
  15781.      both forms.  For example, `-?' and `--help' are the short and long
  15782.      forms of the option that instructs a MySQL program to display a
  15783.      help message.
  15784.  
  15785.    * Option names are case sensitive.  `-v' and `-V' are both legal and
  15786.      have different meanings. (They are the corresponding short forms
  15787.      of the `--verbose' and `--version' options.)
  15788.  
  15789.    * Some options take a value following the option name.  For example,
  15790.      `-h localhost' or `--host=localhost' indicate the MySQL server
  15791.      host to a client program.  The option value tells the program the
  15792.      name of the host where the MySQL server is running.
  15793.  
  15794.    * For a long option that takes a value, separate the option name and
  15795.      the value by an `=' sign.  For a short option that takes a value,
  15796.      the option value can immediately follow the option letter, or
  15797.      there can be a space between.  (`-hlocalhost' and `-h localhost'
  15798.      are equivalent.)  An exception to this rule is the option for
  15799.      specifying your MySQL password.  This option can be given in long
  15800.      form as `--password=pass_val' or as `--password'. In the latter
  15801.      case (with no password value given), the program will prompt you
  15802.      for the password.  The password option also may be given in short
  15803.      form as `-ppass_val' or as `-p'. However, for the short form, if
  15804.      the password value is given, it must follow the option letter with
  15805.      _no intervening space_. The reason for this is that if a space
  15806.      follows the option letter, the program has no way to tell whether
  15807.      a following argument is supposed to be the password value or some
  15808.      other kind of argument.  Consequently, the following two commands
  15809.      have two completely different meanings:
  15810.  
  15811.           shell> mysql -ptest
  15812.           shell> mysql -p test
  15813.  
  15814.      The first command instructs `mysql' to use a password value of
  15815.      `test', but specifies no default database.  The second instructs
  15816.      `mysql' to prompt for the password value and to use `test' as the
  15817.      default database.
  15818.  
  15819.  
  15820. MySQL 4.0 introduced some additional flexibility in the way you specify
  15821. options. These changes were made in MySQL 4.0.2. Some of them relate to
  15822. the way you specify options that have "enabled" and "disabled" states,
  15823. and to the use of options that might be present in one version of MySQL
  15824. but not another.  Those capabilities are discussed in this section.
  15825. Another change pertains to the way you use options to set program
  15826. variables.  *Note Program variables:: discusses that topic further.
  15827.  
  15828. Some options control behavior that can be turned on or off. For example,
  15829. the `mysql' client supports a `--column-names' option that determines
  15830. whether or not to display a row of column names at the beginning of
  15831. query results. By default, this option is enabled. However, you may
  15832. want to disable it in some instances, such as when sending the output
  15833. of `mysql' into another program that expects to see only data and not
  15834. an initial header line.
  15835.  
  15836. To disable column names, you can specify the option using any of these
  15837. forms:
  15838.  
  15839.      --disable-column-names
  15840.      --skip-column-names
  15841.      --column-names=0
  15842.  
  15843. The `--disable' and `--skip' prefixes and the `=0' suffix all have the
  15844. same effect: They turn the option off.
  15845.  
  15846. The "enabled" form of the option may be specified in any of these ways:
  15847.  
  15848.      --column-names
  15849.      --enable-column-names
  15850.      --column-names=1
  15851.  
  15852. Another change to option processing introduced in MySQL 4.0 is that you
  15853. can use the `--loose' prefix for command-line options. If an option is
  15854. prefixed by `--loose', the program will not exit with an error if it
  15855. does not recognize the option, but instead will issue only a warning:
  15856.  
  15857.      shell> mysql --loose-no-such-option
  15858.      mysql: WARNING: unknown option '--no-such-option'
  15859.  
  15860. The `--loose' prefix can be useful when you run programs from multiple
  15861. installations of MySQL on the same machine, at least if all the
  15862. versions are as recent as 4.0.2.  This prefix is particularly useful
  15863. when you list options in an option file.  An option that may not be
  15864. recognized by all versions of a program can be given using the `--loose'
  15865. prefix (or `loose' in an option file). Versions of the program that do
  15866. not recognize the option will issue a warning and ignore it. This
  15867. strategy requires that versions involved be 4.0.2 or later, because
  15868. earlier versions know nothing of the `--loose' convention.
  15869.  
  15870. Using Option Files
  15871. ------------------
  15872.  
  15873. MySQL programs can read startup options from option files (also
  15874. sometimes called configuration files).  Option files provide a
  15875. convenient way to specify commonly used options so that they need not
  15876. be entered on the command line each time you run a program.  Option
  15877. file capability is available from MySQL 3.22 on.
  15878.  
  15879. The following programs support option files: `myisamchk', `myisampack',
  15880. `mysql', `mysql.server', `mysqladmin', `mysqlbinlog', `mysqlcc',
  15881. `mysqlcheck', `mysqld_safe', `mysqldump', `mysqld', `mysqlhotcopy',
  15882. `mysqlimport', and `mysqlshow'.
  15883.  
  15884. On Windows, MySQL programs read startup options from the following
  15885. files:
  15886.  
  15887. *Filename*             *Purpose*
  15888. `WINDIR\my.ini'        Global options
  15889. `C:\my.cnf'            Global options
  15890.  
  15891. WINDIR represents the location of your Windows directory.  This is
  15892. commonly `C:\Windows' or `C:\WinNT'.  You can determine its exact
  15893. location from the value of the `WINDIR' environment variable using the
  15894. following command:
  15895.  
  15896.      C:\> echo %WINDIR%
  15897.  
  15898. On Unix, MySQL programs read startup options from the following files:
  15899.  
  15900. *Filename*             *Purpose*
  15901. `/etc/my.cnf'          Global options
  15902. `DATADIR/my.cnf'       Server-specific options
  15903. `defaults-extra-file'  The file specified with
  15904.                        `--defaults-extra-file=PATH', if any
  15905. `~/.my.cnf'            User-specific options
  15906.  
  15907. DATADIR represents the location of the MySQL data directory. Typically
  15908. this is `/usr/local/mysql/data' for a binary installation or
  15909. `/usr/local/var' for a source installation.  Note that this is the data
  15910. directory location that was specified at configuration time, not the
  15911. one specified with `--datadir' when `mysqld' starts.  Use of
  15912. `--datadir' at runtime has no effect on where the server looks for
  15913. option files, because it looks for them before processing any
  15914. command-line arguments.
  15915.  
  15916. MySQL looks for option files in the order just described and reads any
  15917. that exist. If an option file that you want to use does not exist,
  15918. create it with a plain text editor.  If multiple option files exist, an
  15919. option specified in a file read later takes precedence over the same
  15920. option specified in a file read earlier.
  15921.  
  15922. Any long option that may be given on the command line when running a
  15923. MySQL program can be given in an option file as well.  To get the list
  15924. of available options for a program, run it with the `--help' option.
  15925.  
  15926. The syntax for specifying options in an option file is similar to
  15927. command-line syntax, except that you omit the leading two dashes. For
  15928. example, `--quick' or `--host=localhost' on the command line should be
  15929. specified as `quick' or `host=localhost' in an option file.  To specify
  15930. an option of the form `--loose-opt_name' in an option file, write it as
  15931. `loose-opt_name'.
  15932.  
  15933. Empty lines in option files are ignored. Non-empty lines can take any
  15934. of the following forms:
  15935.  
  15936. `#COMMENT'
  15937. `;COMMENT'
  15938.      Comment lines start with `#' or `;'. As of MySQL 4.0.14, a
  15939.      `#'-comment can start in the middle of a line as well.
  15940.  
  15941. `[GROUP]'
  15942.      GROUP is the name of the program or group for which you want to set
  15943.      options.  After a group line, any OPT_NAME or `set-variable' lines
  15944.      apply to the named group until the end of the option file or
  15945.      another group line is given.
  15946.  
  15947. `OPT_NAME'
  15948.      This is equivalent to `--OPT_NAME' on the command line.
  15949.  
  15950. `OPT_NAME=VALUE'
  15951.      This is equivalent to `--OPT_NAME=VALUE' on the command line.  In
  15952.      an option file, you can have spaces around the `=' character,
  15953.      something that is not true on the command line.  As of MySQL
  15954.      4.0.16, you can quote the value with double quotes or single
  15955.      quotes.  This is useful if the value contains a `#' comment
  15956.      character or whitespace.
  15957.  
  15958. `set-variable = VAR_NAME=VALUE'
  15959.      Set the program variable VAR_NAME to the given value.  This is
  15960.      equivalent to `--set-variable=VAR_NAME=VALUE' on the command line.
  15961.      Spaces are allowed around the first `=' character but not around
  15962.      the second.  This syntax is deprecated as of MySQL 4.0.  See *Note
  15963.      Program variables:: for more information on setting program
  15964.      variables.
  15965.  
  15966. Leading and trailing blanks are automatically deleted from option names
  15967. and values.  You may use the escape sequences `\b', `\t', `\n', `\r',
  15968. `\\', and `\s' in option values to represent the backspace, tab,
  15969. newline, carriage return, and space characters.
  15970.  
  15971. On Windows, if an option value represents a pathname, you should
  15972. specify the value using `/' rather than `\' as the pathname separator.
  15973. If you use `\', you must double it as `\\', because `\' is the escape
  15974. character in MySQL.
  15975.  
  15976. If an option group name is the same as a program name, options in the
  15977. group apply specifically to that program.
  15978.  
  15979. The `[client]' option group is read by all client programs (but not by
  15980. `mysqld'). This allows you to specify options that apply to every
  15981. client. For example, `[client]' is the perfect group to use to specify
  15982. the password that you use to connect to the server.  (But make sure that
  15983. the option file is readable and writable only by yourself, so that other
  15984. people cannot find out your password.) Be sure not to put an option in
  15985. the `[client]' group unless it is recognized by _all_ client programs
  15986. that you use. Programs that do not understand the option will quit after
  15987. displaying an error message if you try to run them.
  15988.  
  15989. As of MySQL 4.0.14, if you want to create option groups that should be
  15990. read only by one specific `mysqld' server release series, you can do
  15991. this by using groups with names of `[mysqld-4.0]', `[mysqld-4.1]', and
  15992. so forth. The following group indicates that the `--new' option should
  15993. be used only by MySQL servers with 4.0.x version numbers:
  15994.  
  15995.      [mysqld-4.0]
  15996.      new
  15997.  
  15998. Here is a typical global option file:
  15999.  
  16000.      [client]
  16001.      port=3306
  16002.      socket=/tmp/mysql.sock
  16003.      
  16004.      [mysqld]
  16005.      port=3306
  16006.      socket=/tmp/mysql.sock
  16007.      key_buffer_size=16M
  16008.      max_allowed_packet=8M
  16009.      
  16010.      [mysqldump]
  16011.      quick
  16012.  
  16013. The preceding option file uses `VAR_NAME=VALUE' syntax for the lines
  16014. that set the `key_buffer_size' and `max_allowed_packet' variables.
  16015. Prior to MySQL 4.0.2, you would need to use `set-variable' syntax
  16016. instead (described earlier in this section).
  16017.  
  16018. Here is a typical user option file:
  16019.  
  16020.      [client]
  16021.      # The following password will be sent to all standard MySQL clients
  16022.      password="my_password"
  16023.      
  16024.      [mysql]
  16025.      no-auto-rehash
  16026.      set-variable = connect_timeout=2
  16027.      
  16028.      [mysqlhotcopy]
  16029.      interactive-timeout
  16030.  
  16031. This option file uses `set-variable' syntax to set the
  16032. `connect_timeout' variable. For MySQL 4.0.2 and up, you can also set
  16033. the variable using just `connect_timeout=2'.
  16034.  
  16035. If you have a source distribution, you will find sample option files
  16036. named `my-XXXX.cnf' in the `support-files' directory.  If you have a
  16037. binary distribution, look in the `support-files' directory under your
  16038. MySQL installation directory (typically `C:\mysql' on Windows or
  16039. `/usr/local/mysql' on Unix).  Currently there are sample option files
  16040. for small, medium, large, and very large systems. To experiment with
  16041. one of these files, copy it to `C:\my.cnf' on Windows or to `.my.cnf'
  16042. in your home directory on Unix.
  16043.  
  16044. *Note*: On Windows, the `.cnf' option file extension might not be
  16045. displayed.
  16046.  
  16047. All MySQL programs that support option files handle the following
  16048. command-line options:
  16049.  
  16050. `--no-defaults'
  16051.      Don't read any option files.
  16052.  
  16053. `--print-defaults'
  16054.      Print the program name and all options that it will get from
  16055.      option files.
  16056.  
  16057. `--defaults-file=PATH_NAME'
  16058.      Use only the given option file. PATH_NAME is the full pathname to
  16059.      the file.
  16060.  
  16061. `--defaults-extra-file=PATH_NAME'
  16062.      Read this option file after the global option file but before the
  16063.      user option file. PATH_NAME is the full pathname to the file.
  16064.  
  16065. To work properly, each of these options must immediately follow the
  16066. command name on the command line, with the exception that
  16067. `--print-defaults' may be used immediately after `--defaults-file' or
  16068. `--defaults-extra-file'.
  16069.  
  16070. In shell scripts, you can use the `my_print_defaults' program to parse
  16071. option files. The following example shows the output that
  16072. `my_print_defaults' might produce when asked to show the options found
  16073. in the `[client]' and `[mysql]' groups:
  16074.  
  16075.      shell> my_print_defaults client mysql
  16076.      --port=3306
  16077.      --socket=/tmp/mysql.sock
  16078.      --no-auto-rehash
  16079.  
  16080. Note for developers:  Option file handling is implemented in the C
  16081. client library simply by processing all matching options (that is,
  16082. options in the appropriate group) before any command-line arguments.
  16083. This works nicely for programs that use the last instance of an option
  16084. that is specified multiple times. If you have a C or C++ program that
  16085. handles multiply specified options this way but doesn't read option
  16086. files, you need add only two lines to give it that capability.  Check
  16087. the source code of any of the standard MySQL clients to see how to do
  16088. this.
  16089.  
  16090. Several other language interfaces to MySQL are based on the C client
  16091. library, and some of them provide a way to access option file contents.
  16092. These include Perl and Python. See the documentation for your preferred
  16093. interface for details.
  16094.  
  16095. Using Environment Variables to Specify Options
  16096. ----------------------------------------------
  16097.  
  16098. To specify an option using an environment variable, set the variable
  16099. using the syntax appropriate for your comment processor. For example,
  16100. on Windows or NetWare, you can set the `USER' variable to specify your
  16101. MySQL account name.  To do so, use this syntax:
  16102.  
  16103.      SET USER=YOUR_NAME
  16104.  
  16105. The syntax on Unix depends on your shell. Suppose that you want to
  16106. specify the TCP/IP port number using the `MYSQL_TCP_PORT' variable. The
  16107. syntax for Bourne shell and variants (`sh', `bash', `zsh', etc.) is:
  16108.  
  16109.      MYSQL_TCP_PORT=3306
  16110.  
  16111. For `csh' and `tcsh', use this syntax:
  16112.  
  16113.      setenv MYSQL_TCP_PORT 3306
  16114.  
  16115. The commands to set environment variables can be executed at your
  16116. command prompt to take effect immediately. These settings persist until
  16117. you log out.  To have the settings take effect each time you log in,
  16118. place the appropriate command or commands in a startup file that your
  16119. command interpreter reads each time it starts. Typical startup files are
  16120. `AUTOEXEC.BAT' for Windows, `.bash_profile' for `bash', or `.tcshrc'
  16121. for `tcsh'. Consult the documentation for your command interpreter for
  16122. specific details.
  16123.  
  16124. *Note Environment variables:: lists all environment variables that
  16125. affect MySQL program operation.
  16126.  
  16127. Using Options to Set Program Variables
  16128. --------------------------------------
  16129.  
  16130. Many MySQL programs have internal variables that can be set at runtime.
  16131. As of MySQL 4.0.2, program variables are set the same way as any other
  16132. long option that takes a value.  For example, `mysql' has a
  16133. `max_allowed_packet' variable that controls the maximum size of its
  16134. communication buffer.  To set the `max_allowed_packet' variable for
  16135. `mysql' to a value of 16MB, use either of the following commands:
  16136.  
  16137.      shell> mysql --max_allowed_packet=16777216
  16138.      shell> mysql --max_allowed_packet=16M
  16139.  
  16140. The first command specifies the value in bytes. The second specifies
  16141. the value in megabytes. Variable values can have a suffix of `K', `M',
  16142. or `G' (either uppercase or lowercase) to indicate units of kilobytes,
  16143. megabytes, or gigabytes.
  16144.  
  16145. In an option file, the variable setting is given without the leading
  16146. dashes:
  16147.  
  16148.      [mysql]
  16149.      max_allowed_packet=16777216
  16150.  
  16151. Or:
  16152.  
  16153.      [mysql]
  16154.      max_allowed_packet=16M
  16155.  
  16156. If you like, underscores in a variable name can be specified as dashes.
  16157.  
  16158. Prior to MySQL 4.0.2, program variable names are not recognized as
  16159. option names.  Instead, use the `--set-variable' option to assign a
  16160. value to a variable:
  16161.  
  16162.      shell> mysql --set-variable=max_allowed_packet=16777216
  16163.      shell> mysql --set-variable=max_allowed_packet=16M
  16164.  
  16165. In an option file, omit the leading dashes:
  16166.  
  16167.      [mysql]
  16168.      set-variable = max_allowed_packet=16777216
  16169.  
  16170. Or:
  16171.  
  16172.      [mysql]
  16173.      set-variable = max_allowed_packet=16M
  16174.  
  16175. With `--set-variable', underscores in variable names cannot be given as
  16176. dashes for versions of MySQL older than 4.0.2.
  16177.  
  16178. The `--set-variable' option is still recognized in MySQL 4.0.2 and up,
  16179. but is deprecated.
  16180.  
  16181. Some server variables can be set at runtime. For details, see *Note
  16182. Dynamic System Variables::.
  16183.  
  16184. Database Administration
  16185. ***********************
  16186.  
  16187. This chapter covers topics that deal with administering a MySQL
  16188. installation, such as configuring the server, managing user accounts,
  16189. and performing backups.
  16190.  
  16191. The MySQL Server and Server Startup Scripts
  16192. ===========================================
  16193.  
  16194. The MySQL server, `mysqld', is the main program that does most of the
  16195. work in a MySQL installation. The server is accompanied by several
  16196. related scripts that perform setup operations when you install MySQL or
  16197. that are helper programs to assist you in starting and stopping the
  16198. server.
  16199.  
  16200. This section provides an overview of the server and related programs,
  16201. and information about server startup scripts. Information about
  16202. configuring the server itself is given in *Note Configuring MySQL::.
  16203.  
  16204. Overview of the Server-Side Scripts and Utilities
  16205. -------------------------------------------------
  16206.  
  16207. All MySQL programs take many different options. However, every MySQL
  16208. program provides a `--help' option that you can use to get a
  16209. description of the program's options. For example, try `mysqld --help'.
  16210.  
  16211. You can override default options for all standard programs by specifying
  16212. options on the command line or in an option file.  *Note Program
  16213. Options::.
  16214.  
  16215. The following list briefly describes the MySQL server and server-related
  16216. programs:
  16217.  
  16218. `mysqld'
  16219.      The SQL daemon (that is, the MySQL server). To use client
  16220.      programs, this program must be running, because clients gain
  16221.      access to databases by connecting to the server.  *Note
  16222.      Configuring MySQL::.
  16223.  
  16224. `mysqld-max'
  16225.      A version of the server that includes additional features.  *Note
  16226.      `mysqld-max': mysqld-max.
  16227.  
  16228. `mysqld_safe'
  16229.      A server startup script.  `mysqld_safe' attempts to start
  16230.      `mysqld-max' if it exists, and `mysqld' otherwise.  *Note
  16231.      `mysqld_safe': mysqld_safe.
  16232.  
  16233. `mysql.server'
  16234.      A server startup script.  This script is used on systems that use
  16235.      run directories containing scripts that start system services for
  16236.      particular run levels. It invokes `mysqld_safe' to start the MySQL
  16237.      server.  *Note `mysql.server': mysql.server.
  16238.  
  16239. `mysqld_multi'
  16240.      A server startup script that can start or stop multiple servers
  16241.      installed on the system.  *Note `mysqld_multi': mysqld_multi.
  16242.  
  16243. `mysql_install_db'
  16244.      This script creates the MySQL grant tables with default
  16245.      privileges. It is usually executed only once, when first
  16246.      installing MySQL on a system.
  16247.  
  16248. `mysql_fix_privilege_tables'
  16249.      This script is used after an upgrade install operation, to update
  16250.      the grant tables with any changes that have been made in newer
  16251.      versions of MySQL.
  16252.  
  16253. There are several other programs that also are run on the server host:
  16254.  
  16255. `myisamchk'
  16256.      A utility to describe, check, optimize, and repair `MyISAM' tables.
  16257.      `myisamchk' is described in *Note Table maintenance::.
  16258.  
  16259. `make_binary_distribution'
  16260.      This program makes a binary release of a compiled MySQL. This
  16261.      could be sent by FTP to `/pub/mysql/upload/' on `ftp.mysql.com'
  16262.      for the convenience of other MySQL users.
  16263.  
  16264. `mysqlbug'
  16265.      The MySQL bug reporting script.  It can be used to send a bug
  16266.      report to the MySQL mailing list. (You can also visit
  16267.      `http://bugs.mysql.com/' to file a bug report online.)
  16268.  
  16269. The `mysqld-max' Extended MySQL Server
  16270. --------------------------------------
  16271.  
  16272. A MySQL-Max server is a version of the `mysqld' MySQL server that has
  16273. been built to include additional features.
  16274.  
  16275. The distribution to use depends on your platform:
  16276.  
  16277.    * For Windows, MySQL binary distributions include both the standard
  16278.      server (`mysqld.exe') and the MySQL-Max server (`mysqld-max.exe'),
  16279.      so you need not get a special distribution. Just use a regular
  16280.      Windows distribution, available at
  16281.      `http://dev.mysql.com/downloads/mysql-4.0.html'.  *Note Windows
  16282.      installation::.
  16283.  
  16284.    * For Linux, if you install MySQL using RPM distributions, use the
  16285.      regular `MySQL-server' RPM first to install a standard server named
  16286.      `mysqld'.  Then use the `MySQL-Max' RPM to install a server named
  16287.      `mysqld-max'.  The `MySQL-Max' RPM presupposes that you have
  16288.      already installed the regular server RPM.  See *Note Linux-RPM::
  16289.      for more information on the Linux RPM packages.
  16290.  
  16291.    * All other MySQL-Max distributions contain a single server that is
  16292.      named `mysqld' but that has the additional features included.
  16293.  
  16294.  
  16295. You can find the MySQL-Max binaries on the MySQL AB Web site at
  16296. `http://dev.mysql.com/downloads/mysql-4.0.html'.
  16297.  
  16298. MySQL AB builds the MySQL-Max servers by using the following
  16299. `configure' options:
  16300.  
  16301. `--with-server-suffix=-max'
  16302.      This option adds a `-max' suffix to the `mysqld' version string.
  16303.  
  16304. `--with-innodb'
  16305.      This option enables support for the `InnoDB' storage engine.
  16306.      MySQL-Max servers always include `InnoDB' support, but this option
  16307.      actually is needed only for MySQL 3.23.  From MySQL 4 on, `InnoDB'
  16308.      is included by default in binary distributions, so you do not need
  16309.      a MySQL-Max server to obtain `InnoDB' support.
  16310.  
  16311. `--with-bdb'
  16312.      This option enables support for the Berkeley DB (`BDB') storage
  16313.      engine.
  16314.  
  16315. `CFLAGS=-DUSE_SYMDIR'
  16316.      This define enables symbolic link support for Windows.
  16317.  
  16318. MySQL-Max binary distributions are a convenience for those who wish to
  16319. install precompiled programs. If you build MySQL using a source
  16320. distribution, you can build your own Max-like server by enabling the
  16321. same features at configuration time that the MySQL-Max binary
  16322. distributions are built with.
  16323.  
  16324. MySQL-Max servers include the BerkeleyDB (`BDB') storage engine
  16325. whenever possible, but not all platforms support `BDB'.  The following
  16326. table shows which platforms allow MySQL-Max binaries to include `BDB':
  16327.  
  16328. *System*       `BDB'
  16329.                *Support*
  16330. AIX 4.3        N
  16331. HP-UX 11.0     N
  16332. Linux-Alpha    N
  16333. Linux-IA-64    N
  16334. Linux-Intel    Y
  16335. Mac OS X       N
  16336. NetWare        N
  16337. SCO OSR5       Y
  16338. Solaris-Intel  N
  16339. Solaris-SPARC  Y
  16340. UnixWare       Y
  16341. Windows/NT     Y
  16342.  
  16343. To find out which storage engines your server supports, issue the
  16344. following statement:
  16345.  
  16346.      mysql> SHOW ENGINES;
  16347.  
  16348. Before MySQL 4.1.2, `SHOW ENGINES' is unavailable. Use the following
  16349. statement instead and check the value of the variable for the storage
  16350. engine in which you are interested:
  16351.  
  16352.      mysql> SHOW VARIABLES LIKE 'have_%';
  16353.      +------------------+----------+
  16354.      | Variable_name    | Value    |
  16355.      +------------------+----------+
  16356.      | have_bdb         | NO       |
  16357.      | have_crypt       | YES      |
  16358.      | have_innodb      | YES      |
  16359.      | have_isam        | NO       |
  16360.      | have_raid        | NO       |
  16361.      | have_symlink     | DISABLED |
  16362.      | have_openssl     | NO       |
  16363.      | have_query_cache | YES      |
  16364.      +------------------+----------+
  16365.  
  16366. The values in the second column indicate the server's level of support
  16367. for each feature:
  16368.  
  16369. *Value*     *Meaning*
  16370. `YES'       The feature is supported and is active.
  16371. `NO'        The feature is not supported.
  16372. `DISABLED'  The feature is supported but has been disabled.
  16373.  
  16374. A value of `NO' means that the server was compiled without support for
  16375. the feature, so it cannot be activated at runtime.
  16376.  
  16377. A value of `DISABLED' occurs either because the server was started with
  16378. an option that disables the feature, or because not all options
  16379. required to enable it were given. In the latter case, the
  16380. `HOST_NAME.err' error log file should contain a reason indicating why
  16381. the option is disabled.
  16382.  
  16383. One situation in which you might see `DISABLED' occurs with MySQL 3.23
  16384. when the `InnoDB' storage engine is compiled in. In MySQL 3.23, you
  16385. must supply at least the `innodb_data_file_path' option at runtime to
  16386. set up the `InnoDB' tablespace. Without this option, `InnoDB' disables
  16387. itself.  *Note `InnoDB' in MySQL 3.23: InnoDB in MySQL 3.23.  You can
  16388. specify configuration options for the `BDB' storage engine, too, but
  16389. `BDB' will not disable itself if you do not provide them.  *Note `BDB'
  16390. start: BDB start.
  16391.  
  16392. You might also see `DISABLED' for the `InnoDB', `BDB', or `ISAM'
  16393. storage engines if the server was compiled to support them, but was
  16394. started with the `--skip-innodb', `--skip-bdb', or `--skip-isam'
  16395. options at runtime.
  16396.  
  16397. As of Version 3.23, all MySQL servers support `MyISAM' tables, because
  16398. `MyISAM' is the default storage engine.
  16399.  
  16400. The `mysqld_safe' Server Startup Script
  16401. ---------------------------------------
  16402.  
  16403. `mysqld_safe' is the recommended way to start a `mysqld' server on Unix
  16404. and NetWare.  `mysqld_safe' adds some safety features such as
  16405. restarting the server when an error occurs and logging runtime
  16406. information to an error log file. NetWare-specific behaviors are listed
  16407. later in this section.
  16408.  
  16409. *Note*: Before MySQL 4.0, `mysqld_safe' is named `safe_mysqld'.  To
  16410. preserve backward compatibility, MySQL binary distributions for some
  16411. time will include `safe_mysqld' as a symbolic link to `mysqld_safe'.
  16412.  
  16413. By default, `mysqld_safe' tries to start an executable named
  16414. `mysqld-max' if it exists, or `mysqld' otherwise.  Be aware of the
  16415. implications of this behavior:
  16416.  
  16417.    * On Linux, the `MySQL-Max' RPM relies on this `mysqld_safe'
  16418.      behavior. The RPM installs an executable named `mysqld-max', which
  16419.      causes `mysqld_safe' to automatically use that executable from that
  16420.      point on.
  16421.  
  16422.    * If you install a MySQL-Max distribution that includes a server
  16423.      named `mysqld-max', then upgrade later to a non-Max version of
  16424.      MySQL, `mysqld_safe' will still attempt to run the old `mysqld-max'
  16425.      server.  If you perform such an upgrade, you should manually
  16426.      remove the old `mysqld-max' server to ensure that `mysqld_safe'
  16427.      runs the new `mysqld' server.
  16428.  
  16429.  
  16430. To override the default behavior and specify explicitly which server you
  16431. want to run, specify a `--mysqld' or `--mysqld-version' option to
  16432. `mysqld_safe'.
  16433.  
  16434. Many of the options to `mysqld_safe' are the same as the options to
  16435. `mysqld'. *Note Server options::.
  16436.  
  16437. All options specified to `mysqld_safe' on the command line are passed
  16438. to `mysqld'.  If you want to use any options that are specific to
  16439. `mysqld_safe' and that `mysqld' doesn't support, do not specify them on
  16440. the command line. Instead, list them in the `[mysqld_safe]' group of an
  16441. option file.  *Note Option files::.
  16442.  
  16443. `mysqld_safe' reads all options from the `[mysqld]', `[server]', and
  16444. `[mysqld_safe]' sections in option files.  For backward compatibility,
  16445. it also reads `[safe_mysqld]' sections, although you should rename such
  16446. sections to `[mysqld_safe]' when you begin using MySQL 4.0 or later.
  16447.  
  16448. `mysqld_safe' supports the following options:
  16449.  
  16450. `--basedir=PATH'
  16451.      The path to the MySQL installation directory.
  16452.  
  16453. `--core-file-size=SIZE'
  16454.      The size of the core file `mysqld' should be able to create. The
  16455.      option value is passed to `ulimit -c'.
  16456.  
  16457. `--datadir=PATH'
  16458.      The path to the data directory.
  16459.  
  16460. `--defaults-extra-file=PATH'
  16461.      The name of an option file to be read in addition to the usual
  16462.      option files.
  16463.  
  16464. `--defaults-file=PATH'
  16465.      The name of an option file to be read instead of the usual option
  16466.      files.
  16467.  
  16468. `--err-log=PATH'
  16469.      The old form of the `--log-error' option, to be used before MySQL
  16470.      4.0.
  16471.  
  16472. `--ledir=PATH'
  16473.      The path to the directory containing the `mysqld' program.  Use
  16474.      this option to explicitly indicate the location of the server.
  16475.  
  16476. `--log-error=PATH'
  16477.      Write the error log to the given file. *Note Error log::.
  16478.  
  16479. `--mysqld=PROG_NAME'
  16480.      The name of the server program (in the `ledir' directory) that you
  16481.      want to start. This option is needed if you use the MySQL binary
  16482.      distribution but have the data directory outside of the binary
  16483.      distribution.
  16484.  
  16485. `--mysqld-version=SUFFIX'
  16486.      This option is similar to the `--mysqld' option, but you specify
  16487.      only the suffix for the server program name. The basename is
  16488.      assumed to be `mysqld'.  For example, if you use
  16489.      `--mysqld-version=max', `mysqld_safe' will start the `mysqld-max'
  16490.      program in the `ledir' directory.  If the argument to
  16491.      `--mysqld-version' is empty, `mysqld_safe' uses `mysqld' in the
  16492.      `ledir' directory.
  16493.  
  16494. `--nice=PRIORITY'
  16495.      Use the `nice' program to set the server's scheduling priority to
  16496.      the given value.  This option was added in MySQL 4.0.14.
  16497.  
  16498. `--no-defaults'
  16499.      Do not read any option files.
  16500.  
  16501. `--open-files-limit=COUNT'
  16502.      The number of files `mysqld' should be able to open. The option
  16503.      value is passed to `ulimit -n'. Note that you need to start
  16504.      `mysqld_safe' as `root' for this to work properly!
  16505.  
  16506. `--pid-file=PATH'
  16507.      The path to the process ID file.
  16508.  
  16509. `--port=PORT_NUM'
  16510.      The port number to use when listening for TCP/IP connections.
  16511.  
  16512. `--socket=PATH'
  16513.      The Unix socket file to use for local connections.
  16514.  
  16515. `--timezone=ZONE'
  16516.      Set the `TZ' time zone environment variable to the given option
  16517.      value.  Consult your operating system documentation for legal time
  16518.      zone specification formats.
  16519.  
  16520. `--user={USER_NAME | USER_ID}'
  16521.      Run the `mysqld' server as the user having the name USER_NAME or
  16522.      the numeric user ID USER_ID.  ("User" in this context refers to a
  16523.      system login account, not a MySQL user listed in the grant tables.)
  16524.  
  16525. The `mysqld_safe' script is written so that it normally can start a
  16526. server that was installed from either a source or a binary distribution
  16527. of MySQL, even though these types of distributions typically install
  16528. the server in slightly different locations.  (*Note Installation
  16529. layouts::.)  `mysqld_safe' expects one of the following conditions to
  16530. be true:
  16531.  
  16532.    * The server and databases can be found relative to the directory
  16533.      from which `mysqld_safe' is invoked.  For binary distributions,
  16534.      `mysqld_safe' looks under its working directory for `bin' and
  16535.      `data' directories.  For source distributions, it looks for
  16536.      `libexec' and `var' directories.  This condition should be met if
  16537.      you execute `mysqld_safe' from your MySQL installation directory
  16538.      (for example, `/usr/local/mysql' for a binary distribution).
  16539.  
  16540.    * If the server and databases cannot be found relative to the working
  16541.      directory, `mysqld_safe' attempts to locate them by absolute
  16542.      pathnames.  Typical locations are `/usr/local/libexec' and
  16543.      `/usr/local/var'.  The actual locations are determined from the
  16544.      values configured into the distribution at the time it was built.
  16545.      They should be correct if MySQL is installed in the location
  16546.      specified at configuration time.
  16547.  
  16548. Because `mysqld_safe' will try to find the server and databases relative
  16549. to its own working directory, you can install a binary distribution of
  16550. MySQL anywhere, as long as you run `mysqld_safe' from the MySQL
  16551. installation directory:
  16552.  
  16553.      shell> cd mysql_installation_directory
  16554.      shell> bin/mysqld_safe &
  16555.  
  16556. If `mysqld_safe' fails, even when invoked from the MySQL installation
  16557. directory, you can specify the `--ledir' and `--datadir' options to
  16558. indicate the directories in which the server and databases are located
  16559. on your system.
  16560.  
  16561. Normally, you should not edit the `mysqld_safe' script.  Instead,
  16562. configure `mysqld_safe' by using command-line options or options in the
  16563. `[mysqld_safe]' section of a `my.cnf' option file.  In rare cases, it
  16564. might be necessary to edit `mysqld_safe' to get it to start the server
  16565. properly. However, if you do this, your modified version of
  16566. `mysqld_safe' might be overwritten if you upgrade MySQL in the future,
  16567. so you should make a copy of your edited version that you can reinstall.
  16568.  
  16569. On NetWare, `mysqld_safe' is a NetWare Loadable Module (NLM) that is
  16570. ported from the original Unix shell script.  It does the following:
  16571.  
  16572.   1. Runs a number of system and option checks.
  16573.  
  16574.   2. Runs a check on `MyISAM' and `ISAM' tables.
  16575.  
  16576.   3. Provides a screen presence for the MySQL server.
  16577.  
  16578.   4. Starts `mysqld', monitors it, and restarts it if it terminates in
  16579.      error.
  16580.  
  16581.   5. Sends error messages from `mysqld' to the `HOST_NAME.err' file in
  16582.      the data directory.
  16583.  
  16584.   6. Sends `mysqld_safe' screen output to the `HOST_NAME.safe' file in
  16585.      the data directory.
  16586.  
  16587.  
  16588. The `mysql.server' Server Startup Script
  16589. ----------------------------------------
  16590.  
  16591. MySQL distributions on Unix include a script named `mysql.server'.  It
  16592. can be used on systems such as Linux and Solaris that use System V-style
  16593. run directories to start and stop system services. It is also used by
  16594. the Mac OS X Startup Item for MySQL.
  16595.  
  16596. `mysql.server' can be found in the `support-files' directory under your
  16597. MySQL installation directory or in a MySQL source tree.
  16598.  
  16599. If you use the Linux server RPM package (`MySQL-server-VERSION.rpm'),
  16600. the `mysql.server' script will already have been installed in the
  16601. `/etc/init.d' directory with the name `mysql'. You need not install it
  16602. manually. See *Note Linux-RPM:: for more information on the Linux RPM
  16603. packages.
  16604.  
  16605. Some vendors provide RPM packages that install a startup script under a
  16606. different name such as `mysqld'.
  16607.  
  16608. If you install MySQL from a source distribution or using a binary
  16609. distribution format that does not install `mysql.server' automatically,
  16610. you can install it manually. Instructions are provided in *Note
  16611. Automatic start::.
  16612.  
  16613. `mysql.server' reads options from the `[mysql.server]' and `[mysqld]'
  16614. sections of option files.  (For backward compatibility, it also reads
  16615. `[mysql_server]' sections, although you should rename such sections to
  16616. `[mysql.server]' when you begin using MySQL 4.0 or later.)
  16617.  
  16618. The `mysqld_multi' Program for Managing Multiple MySQL Servers
  16619. --------------------------------------------------------------
  16620.  
  16621. `mysqld_multi' is meant for managing several `mysqld' processes that
  16622. listen for connections on different Unix socket files and TCP/IP ports.
  16623. It can start or stop servers, or report their current status.
  16624.  
  16625. The program searches for groups named `[mysqld#]' in `my.cnf' (or in
  16626. the file named by the `--config-file' option).  `#' can be any positive
  16627. integer.  This number is referred to in the following discussion as the
  16628. option group number, or GNR.  Group numbers distinguish option groups
  16629. from one another and are used as arguments to `mysqld_multi' to specify
  16630. which servers you want to start, stop, or obtain a status report for.
  16631. Options listed in these groups are the same that you would use in the
  16632. `[mysqld]' group used for starting `mysqld'.  (See, for example, *Note
  16633. Automatic start::.) However, when using multiple servers it is necessary
  16634. that each one use its own value for options such as the Unix socket
  16635. file and TCP/IP port number. For more information on which options must
  16636. be unique per server in a multiple-server environment, see *Note
  16637. Multiple servers::.
  16638.  
  16639. To invoke `mysqld_multi', use the following syntax:
  16640.  
  16641.      shell> mysqld_multi [OPTIONS] {start|stop|report} [GNR[,GNR]...]
  16642.  
  16643. `start', `stop', and `report' indicate which operation you want to
  16644. perform. You can perform the designated operation on a single server or
  16645. multiple servers, depending on the GNR list that follows the option
  16646. name.  If there is no list, `mysqld_multi' performs the operation for
  16647. all servers in the option file.
  16648.  
  16649. Each GNR value represents an option group number or range of group
  16650. numbers.  The value should be the number at the end of the group name
  16651. in the option file.  For example, the GNR for a group named `[mysqld17]'
  16652. is `17'.  To specify a range of numbers, separate the first and last
  16653. numbers by a dash.  The GNR value `10-13' represents groups
  16654. `[mysqld10]' through `[mysqld13]'.  Multiple groups or group ranges can
  16655. be specified on the command line, separated by commas.  There must be
  16656. no whitespace characters (spaces or tabs) in the GNR list; anything
  16657. after a whitespace character is ignored.
  16658.  
  16659. This command starts a single server using option group `[mysqld17]':
  16660.  
  16661.      shell> mysqld_multi start 17
  16662.  
  16663. This command stops several servers, using option groups `[mysql8]' and
  16664. `[mysqld10]' through `[mysqld13]':
  16665.  
  16666.      shell> mysqld_multi stop 8,10-13
  16667.  
  16668. For an example of how you might set up an option file, use this command:
  16669.  
  16670.      shell> mysqld_multi --example
  16671.  
  16672. `mysqld_multi' supports the following options:
  16673.  
  16674. `--config-file=NAME'
  16675.      Specify the name of an alternative option file. This affects where
  16676.      `mysqld_multi' looks for `[mysqld#]' option groups.  Without this
  16677.      option, all options are read from the usual `my.cnf' file.  The
  16678.      option does not affect where `mysqld_multi' reads its own options,
  16679.      which are always taken from the `[mysqld_multi]' group in the
  16680.      usual `my.cnf' file.
  16681.  
  16682. `--example'
  16683.      Display a sample option file.
  16684.  
  16685. `--help'
  16686.      Display a help message and exit.
  16687.  
  16688. `--log=NAME'
  16689.      Specify the name of the log file. If the file exists, log output
  16690.      is appended to it.
  16691.  
  16692. `--mysqladmin=PROG_NAME'
  16693.      The `mysqladmin' binary to be used to stop servers.
  16694.  
  16695. `--mysqld=PROG_NAME'
  16696.      The `mysqld' binary to be used. Note that you can specify
  16697.      `mysqld_safe' as the value for this option also. The options are
  16698.      passed to `mysqld'. Just make sure that you have the directory
  16699.      where `mysqld' is located in your `PATH' environment variable
  16700.      setting or fix `mysqld_safe'.
  16701.  
  16702. `--no-log'
  16703.      Print log information to stdout rather than to the log file. By
  16704.      default, output goes to the log file.
  16705.  
  16706. `--password=PASSWORD'
  16707.      The password of the MySQL account to use when invoking
  16708.      `mysqladmin'.  Note that the password value is not optional for
  16709.      this option, unlike for other MySQL programs.
  16710.  
  16711. `--silent'
  16712.      Disable warnings.  This option was added in MySQL 4.1.6.
  16713.  
  16714. `--tcp-ip'
  16715.      Connect to each MySQL server via the TCP/IP port instead of the
  16716.      Unix socket file.  (If a socket file is missing, the server might
  16717.      still be running, but accessible only via the TCP/IP port.)  By
  16718.      default, connections are made using the Unix socket file.  This
  16719.      option affects `stop' and `report' operations.
  16720.  
  16721. `--user=USER_NAME'
  16722.      The username of the MySQL account to use when invoking
  16723.      `mysqladmin'.
  16724.  
  16725. `--verbose'
  16726.      Be more verbose.  This option was added in MySQL 4.1.6.
  16727.  
  16728. `--version'
  16729.      Display version information and exit.
  16730.  
  16731. Some notes about `mysqld_multi':
  16732.  
  16733.    * Make sure that the MySQL account used for stopping the `mysqld'
  16734.      servers (with the `mysqladmin' program) has the same username and
  16735.      password for each server. Also, make sure that the account has the
  16736.      `SHUTDOWN' privilege. If the servers that you want to manage have
  16737.      many different usernames or passwords for the administrative
  16738.      accounts, you might want to create an account on each server that
  16739.      has the same username and password.  For example, you might set up
  16740.      a common `multi_admin' account by executing the following commands
  16741.      for each server:
  16742.  
  16743.           shell> mysql -u root -S /tmp/mysql.sock -pROOT_PASSWORD
  16744.           mysql> GRANT SHUTDOWN ON *.*
  16745.               -> TO 'multi_admin'@'localhost' IDENTIFIED BY 'multipass';
  16746.  
  16747.      *Note Privileges::.  You will have to do this for each `mysqld'
  16748.      server. Change the connection parameters appropriately when
  16749.      connecting to each one.  Note that the host part of the account
  16750.      name must allow you to connect as `multi_admin' from the host
  16751.      where you want to run `mysqld_multi'.
  16752.  
  16753.    * The `--pid-file' option is very important if you are using
  16754.      `mysqld_safe' to start `mysqld' (for example,
  16755.      `--mysqld=mysqld_safe') Every `mysqld' should have its own process
  16756.      ID file. The advantage of using `mysqld_safe' instead of `mysqld'
  16757.      is that `mysqld_safe' "guards" its `mysqld' process and will
  16758.      restart it if the process terminates due to a signal sent using
  16759.      `kill -9', or for other reasons, such as a segmentation fault.
  16760.      Please note that the `mysqld_safe' script might require that you
  16761.      start it from a certain place. This means that you might have to
  16762.      change location to a certain directory before running
  16763.      `mysqld_multi'. If you have problems starting, please see the
  16764.      `mysqld_safe' script. Check especially the lines:
  16765.  
  16766.           ----------------------------------------------------------------
  16767.           MY_PWD=`pwd`
  16768.           # Check if we are starting this relative (for the binary release)
  16769.           if test -d $MY_PWD/data/mysql -a -f ./share/mysql/english/errmsg.sys -a \
  16770.            -x ./bin/mysqld
  16771.           ----------------------------------------------------------------
  16772.  
  16773.      *Note `mysqld_safe': mysqld_safe.  The test performed by these
  16774.      lines should be successful, or you might encounter problems.
  16775.  
  16776.    * The Unix socket file and the TCP/IP port number must be different
  16777.      for every `mysqld'.
  16778.  
  16779.    * You might want to use the `--user' option for `mysqld', but in
  16780.      order to do this you need to run the `mysqld_multi' script as the
  16781.      Unix `root' user. Having the option in the option file doesn't
  16782.      matter; you will just get a warning, if you are not the superuser
  16783.      and the `mysqld' processes are started under your own Unix account.
  16784.  
  16785.    * *Important*: Make sure that the data directory is fully accessible
  16786.      to the Unix account that the specific `mysqld' process is started
  16787.      as. _Do not_ use the Unix root account for this, unless you _know_
  16788.      what you are doing.
  16789.  
  16790.    * *Most important*: Before using `mysqld_multi' be sure that you
  16791.      understand the meanings of the options that are passed to the
  16792.      `mysqld' servers and _why_ you would want to have separate `mysqld'
  16793.      processes.  Beware of the dangers of using multiple `mysqld'
  16794.      servers with the same data directory.  Use separate data
  16795.      directories, unless you _know_ what you are doing.  Starting
  16796.      multiple servers with the same data directory _will not_ give you
  16797.      extra performance in a threaded system.  *Note Multiple servers::.
  16798.  
  16799.  
  16800. The following example shows how you might set up an option file for use
  16801. with `mysqld_multi'.  The first and fifth `[mysqld#]' group were
  16802. intentionally left out from the example to illustrate that you can have
  16803. "gaps" in the option file. This gives you more flexibility.  The order
  16804. in which the `mysqld' programs are started or stopped depends on the
  16805. order in which they appear in the option file.
  16806.  
  16807.      # This file should probably be in your home dir (~/.my.cnf)
  16808.      # or /etc/my.cnf
  16809.      # Version 2.1 by Jani Tolonen
  16810.      
  16811.      [mysqld_multi]
  16812.      mysqld     = /usr/local/bin/mysqld_safe
  16813.      mysqladmin = /usr/local/bin/mysqladmin
  16814.      user       = multi_admin
  16815.      password   = multipass
  16816.      
  16817.      [mysqld2]
  16818.      socket     = /tmp/mysql.sock2
  16819.      port       = 3307
  16820.      pid-file   = /usr/local/mysql/var2/hostname.pid2
  16821.      datadir    = /usr/local/mysql/var2
  16822.      language   = /usr/local/share/mysql/english
  16823.      user       = john
  16824.      
  16825.      [mysqld3]
  16826.      socket     = /tmp/mysql.sock3
  16827.      port       = 3308
  16828.      pid-file   = /usr/local/mysql/var3/hostname.pid3
  16829.      datadir    = /usr/local/mysql/var3
  16830.      language   = /usr/local/share/mysql/swedish
  16831.      user       = monty
  16832.      
  16833.      [mysqld4]
  16834.      socket     = /tmp/mysql.sock4
  16835.      port       = 3309
  16836.      pid-file   = /usr/local/mysql/var4/hostname.pid4
  16837.      datadir    = /usr/local/mysql/var4
  16838.      language   = /usr/local/share/mysql/estonia
  16839.      user       = tonu
  16840.      
  16841.      [mysqld6]
  16842.      socket     = /tmp/mysql.sock6
  16843.      port       = 3311
  16844.      pid-file   = /usr/local/mysql/var6/hostname.pid6
  16845.      datadir    = /usr/local/mysql/var6
  16846.      language   = /usr/local/share/mysql/japanese
  16847.      user       = jani
  16848.  
  16849. *Note Option files::.
  16850.  
  16851. Configuring the MySQL Server
  16852. ============================
  16853.  
  16854. This section discusses MySQL server configuration topics:
  16855.  
  16856.    * Startup options that the server supports
  16857.  
  16858.    * How to set the server SQL mode
  16859.  
  16860.    * Server system variables
  16861.  
  16862.    * Server status variables
  16863.  
  16864. `mysqld' Command-Line Options
  16865. -----------------------------
  16866.  
  16867. When you start the `mysqld' server, you can specify program options
  16868. using any of the methods described in *Note Program Options::. The most
  16869. common methods are to provide options in an option file or on the
  16870. command line. However, in most cases it is desirable to make sure that
  16871. the server uses the same options each time it runs. The best way to
  16872. ensure this is to list them in an option file.  *Note Option files::.
  16873.  
  16874. `mysqld' reads options from the `[mysqld]' and `[server]' groups.
  16875. `mysqld_safe' reads options from the `[mysqld]', `[server]',
  16876. `[mysqld_safe]', and `[safe_mysqld]' groups.  `mysql.server' reads
  16877. options from the `[mysqld]' and `[mysql.server]' groups.  An embedded
  16878. MySQL server usually reads options from the `[server]', `[embedded]',
  16879. and `[XXXXX_SERVER]' groups, where XXXXX is the name of the application
  16880. into which the server is embedded.
  16881.  
  16882. `mysqld' accepts many command-line options.  For a list, execute
  16883. `mysqld --help'. Before MySQL 4.1.1, `--help' prints the full help
  16884. message. As of 4.1.1, it prints a brief message; to see the full list,
  16885. use `mysqld --verbose --help'.
  16886.  
  16887. The following list shows some of the most common server options.
  16888. Additional options are described elsewhere:
  16889.  
  16890.    * Options that affect security: See *Note Privileges options::.
  16891.  
  16892.    * SSL-related options: See *Note SSL options::.
  16893.  
  16894.    * Binary log control options: See *Note Binary log::.
  16895.  
  16896.    * Replication-related options: See *Note Replication Options::.
  16897.  
  16898.    * Options specific to particular storage engines: See *Note `MyISAM'
  16899.      start: MyISAM start, *Note `BDB' start: BDB start, *Note `InnoDB'
  16900.      start: InnoDB start.
  16901.  
  16902.  
  16903. You can also set the value of a server system variable by using the
  16904. variable name as an option, as described later in this section.
  16905.  
  16906. `--help, -?'
  16907.      Display a short help message and exit.  Before MySQL 4.1.1,
  16908.      `--help' displays the full help message.  As of 4.1.1, it displays
  16909.      an abbreviated message only.  Use both the `--verbose' and
  16910.      `--help' options to see the full message.
  16911.  
  16912. `--ansi'
  16913.      Use standard SQL syntax instead of MySQL syntax.  *Note ANSI
  16914.      mode::.  For more precise control over the server SQL mode, use
  16915.      the `--sql-mode' option instead.
  16916.  
  16917. `--basedir=PATH, -b PATH'
  16918.      The path to the MySQL installation directory. All paths are
  16919.      usually resolved relative to this.
  16920.  
  16921. `--big-tables'
  16922.      Allow large result sets by saving all temporary sets in files.
  16923.      This option prevents most "table full" errors, but also slows down
  16924.      queries for which in-memory tables would suffice.  Since MySQL
  16925.      3.23.2, the server is able to handle large result sets
  16926.      automatically by using memory for small temporary tables and
  16927.      switching to disk tables where necessary.
  16928.  
  16929. `--bind-address=IP'
  16930.      The IP address to bind to.
  16931.  
  16932. `--console'
  16933.      Write the error log messages to stderr/stdout even if `--log-error'
  16934.      is specified.  On Windows, `mysqld' will not close the console
  16935.      screen if this option is used.
  16936.  
  16937. `--character-sets-dir=PATH'
  16938.      The directory where character sets are installed.  *Note Character
  16939.      sets::.
  16940.  
  16941. `--chroot=PATH'
  16942.      Put the `mysqld' server in a closed environment during startup by
  16943.      using the `chroot()' system call. This is a recommended security
  16944.      measure as of MySQL 4.0. (MySQL 3.23 is not able to provide a
  16945.      `chroot()' jail that is 100% closed.)  Note that use of this
  16946.      option somewhat limits `LOAD DATA INFILE' and `SELECT ... INTO
  16947.      OUTFILE'.
  16948.  
  16949. `--character-set-server=CHARSET'
  16950.      Use CHARSET as the default server character set.  This option is
  16951.      available as of MySQL 4.1.3.  *Note Character sets::.
  16952.  
  16953. `--core-file'
  16954.      Write a core file if `mysqld' dies.  For some systems, you must
  16955.      also specify the `--core-file-size' option to `mysqld_safe'.
  16956.      *Note `mysqld_safe': mysqld_safe.  Note that on some systems, such
  16957.      as Solaris, you will not get a core file if you are also using the
  16958.      `--user' option.
  16959.  
  16960. `--collation-server=COLLATION'
  16961.      Use COLLATION as the default server collation.  This option is
  16962.      available as of MySQL 4.1.3.  *Note Character sets::.
  16963.  
  16964. `--datadir=PATH, -h PATH'
  16965.      The path to the data directory.
  16966.  
  16967. `--debug[=DEBUG_OPTIONS], -# [DEBUG_OPTIONS]'
  16968.      If MySQL is configured with `--with-debug', you can use this
  16969.      option to get a trace file of what `mysqld' is doing.  The
  16970.      DEBUG_OPTIONS string often is `'d:t:o,FILE_NAME''.  *Note Making
  16971.      trace files::.
  16972.  
  16973. `--default-character-set=CHARSET'
  16974.      Use CHARSET as the default character set.  This option is
  16975.      deprecated in favor of `--character-set-server' as of MySQL 4.1.3.
  16976.      *Note Character sets::.
  16977.  
  16978. `--default-collation=COLLATION'
  16979.      Use COLLATION as the default collation.  This option is deprecated
  16980.      in favor of `--collation-server' as of MySQL 4.1.3.  *Note
  16981.      Character sets::.
  16982.  
  16983. `--default-storage-engine=TYPE'
  16984.      This option is a synonym for `--default-table-type'.  It is
  16985.      available as of MySQL 4.1.2.
  16986.  
  16987. `--default-table-type=TYPE'
  16988.      Set the default table type for tables.  *Note Storage engines::.
  16989.  
  16990. `--default-time-zone=TYPE'
  16991.      Set the default server time zone.  This option sets the global
  16992.      `time_zone' system variable.  If this option is not given, the
  16993.      default time zone will be the same as the system time zone (given
  16994.      by the value of the `system_time_zone' system variable.  This
  16995.      option is available as of MySQL 4.1.3.
  16996.  
  16997. `--delay-key-write[= OFF | ON | ALL]'
  16998.      How the `DELAYED KEYS' option should be used.  Delayed key writing
  16999.      causes key buffers not to be flushed between writes for `MyISAM'
  17000.      tables.  `OFF' disables delayed key writes.  `ON' enables delayed
  17001.      key writes for those tables that were created with the `DELAYED
  17002.      KEYS' option.  `ALL' delays key writes for all `MyISAM' tables.
  17003.      Available as of MySQL 4.0.3.  *Note Server parameters::. *Note
  17004.      MyISAM start::.
  17005.  
  17006.      *Note*: If you set this variable to `ALL', you should not use
  17007.      `MyISAM' tables from within another program (such as from another
  17008.      MySQL server or with `myisamchk') when the table is in use. Doing
  17009.      so will lead to index corruption.
  17010.  
  17011. `--delay-key-write-for-all-tables'
  17012.      Old form of `--delay-key-write=ALL' for use prior to MySQL 4.0.3.
  17013.      As of 4.0.3, use `--delay-key-write' instead.
  17014.  
  17015. `--des-key-file=FILE_NAME'
  17016.      Read the default keys used by `DES_ENCRYPT()' and `DES_DECRYPT()'
  17017.      from this file.
  17018.  
  17019. `--enable-named-pipe'
  17020.      Enable support for named pipes.  This option applies only on
  17021.      Windows NT, 2000, and XP systems, and can be used only with the
  17022.      `mysqld-nt' and `mysqld-max-nt' servers that support named pipe
  17023.      connections.
  17024.  
  17025. `--exit-info[=FLAGS], -T [FLAGS]'
  17026.      This is a bit mask of different flags you can use for debugging the
  17027.      `mysqld' server. Do not use this option unless you know exactly
  17028.      what it does!
  17029.  
  17030. `--external-locking'
  17031.      Enable system locking.  Note that if you use this option on a
  17032.      system on which `lockd' does not fully work (as on Linux), you
  17033.      will easily get `mysqld' to deadlock.  This option previously was
  17034.      named `--enable-locking'.
  17035.  
  17036.      *Note*: If you use this option to enable updates to `MyISAM'
  17037.      tables from many MySQL processes, you have to ensure that these
  17038.      conditions are satisfied:
  17039.  
  17040.         * You should not use the query cache for queries that use
  17041.           tables that are updated by another process.
  17042.  
  17043.         * You should not use `--delay-key-write=ALL' or
  17044.           `DELAY_KEY_WRITE=1' on any shared tables.
  17045.  
  17046.      The easiest way to ensure this is to always use
  17047.      `--external-locking' together with `--delay-key-write=OFF
  17048.      --query-cache-size=0'.
  17049.  
  17050.      (This is not done by default because in many setups it's useful to
  17051.      have a mixture of the above options.)
  17052.  
  17053. `--flush'
  17054.      Flush all changes to disk after each SQL statement.  Normally MySQL
  17055.      does a write of all changes to disk only after each SQL statement
  17056.      and lets the operating system handle the synching to disk.  *Note
  17057.      Crashing::.
  17058.  
  17059. `--init-file=FILE'
  17060.      Read SQL statements from this file at startup.  Each statement
  17061.      must be on a single line and should not include comments.
  17062.  
  17063. `--innodb-safe-binlog'
  17064.      Adds consistency guarantees between the content of `InnoDB' tables
  17065.      and the binary log.  *Note Binary log::.
  17066.  
  17067. `--language=LANG_NAME, -L LANG_NAME'
  17068.      Client error messages in given language.  LANG_NAME can be given
  17069.      as the language name or as the full pathname to the directory
  17070.      where the language files are installed.  *Note Languages::.
  17071.  
  17072. `--log[=FILE], -l [FILE]'
  17073.      Log connections and queries to this file. *Note Query log::. If
  17074.      you don't specify a filename, MySQL will use `HOST_NAME.log' as
  17075.      the filename.
  17076.  
  17077. `--log-bin=[FILE]'
  17078.      The binary log file.  Log all queries that change data to this
  17079.      file. Used for backup and replication.  *Note Binary log::.  If
  17080.      you don't specify a filename, MySQL will use `HOST_NAME-bin' as
  17081.      the filename.
  17082.  
  17083. `--log-bin-index[=FILE]'
  17084.      The index file for binary log filenames. *Note Binary log::.  If
  17085.      you don't specify a filename, MySQL will use `HOST_NAME-bin.index'
  17086.      as the filename.
  17087.  
  17088. `--log-error[=FILE]'
  17089.      Log errors and startup messages to this file. *Note Error log::.
  17090.      If you don't specify a filename, MySQL will use `HOST_NAME.err' as
  17091.      the filename.
  17092.  
  17093. `--log-isam[=FILE]'
  17094.      Log all `ISAM'/`MyISAM' changes to this file (used only when
  17095.      debugging `ISAM'/`MyISAM').
  17096.  
  17097. `--log-long-format'
  17098.      Log some extra information to the log files (update log, binary
  17099.      update log, and slow queries log, whatever log has been
  17100.      activated). For example, username and timestamp are logged for
  17101.      queries. If you are using `--log-slow-queries' and
  17102.      `--log-long-format', queries that are not using indexes also are
  17103.      logged to the slow query log.  Note that `--log-long-format' is
  17104.      deprecated as of MySQL version 4.1, when `--log-short-format' was
  17105.      introduced (the long log format is the default setting since
  17106.      version 4.1). Also note that starting with MySQL 4.1, the
  17107.      `--log-queries-not-using-indexes' option is available for the
  17108.      purpose of logging queries that do not use indexes to the slow
  17109.      query log.
  17110.  
  17111. `--log-queries-not-using-indexes'
  17112.      If you are using this option with `--log-slow-queries', then
  17113.      queries that are not using indexes also  are logged to the slow
  17114.      query log. This option is available as of MySQL 4.1. *Note Slow
  17115.      query log::.
  17116.  
  17117. `--log-short-format'
  17118.      Log less information to the log files (update log, binary update
  17119.      log, and slow queries log, whatever log has been activated). For
  17120.      example, username and timestamp are not logged for queries. This
  17121.      option was introduced in MySQL 4.1.
  17122.  
  17123. `--log-slow-queries[=FILE]'
  17124.      Log all queries that have taken more than `long_query_time' seconds
  17125.      to execute to this file.  *Note Slow query log::.  Note that the
  17126.      default for the amount of information logged has changed in MySQL
  17127.      4.1. See the `--log-long-format' and `--log-short-format' options
  17128.      for details.
  17129.  
  17130. `--log-update[=FILE]'
  17131.      Log updates to FILE# where # is a unique number if not given.
  17132.      *Note Update log::. The update log is deprecated and is removed in
  17133.      MySQL 5.0.0; you should use the binary log instead (`--log-bin').
  17134.      *Note Binary log::. Starting from version 5.0.0, using
  17135.      `--log-update' will just turn on the binary log instead (*note
  17136.      News-5.0.0::).
  17137.  
  17138. `--log-warnings, -W'
  17139.      Print out warnings such as `Aborted connection...' to the error
  17140.      log.  Enabling this option is recommended, for example, if you use
  17141.      replication (you will get more information about what is happening,
  17142.      such as messages about network failures and reconnections).  This
  17143.      option is enabled by default as of MySQL 4.0.19 and 4.1.2; to
  17144.      disable it, use `--skip-log-warnings'.  As of MySQL 4.0.21 and
  17145.      4.1.3, aborted connections are not logged to the error log unless
  17146.      the value is greater than 1.  *Note Communication errors::.
  17147.  
  17148.      This option was named `--warnings' before MySQL 4.0.
  17149.  
  17150. `--low-priority-updates'
  17151.      Table-modifying operations (`INSERT', `REPLACE', `DELETE',
  17152.      `UPDATE') will have lower priority than selects.  This can also be
  17153.      done via `{INSERT | REPLACE | DELETE | UPDATE} LOW_PRIORITY ...'
  17154.      to lower the priority of only one query, or by `SET
  17155.      LOW_PRIORITY_UPDATES=1' to change the priority in one thread.
  17156.      *Note Table locking::.
  17157.  
  17158. `--memlock'
  17159.      Lock the `mysqld' process in memory.  This works on systems such as
  17160.      Solaris that support the `mlockall()' system call.  This might
  17161.      help if you have a problem where the operating system is causing
  17162.      `mysqld' to swap on disk.  Note that use of this option requires
  17163.      that you run the server as `root', which is normally not a good
  17164.      idea for security reasons.
  17165.  
  17166. `--myisam-recover [=OPTION[,OPTION...]]]'
  17167.      Set the `MyISAM' storage engine recovery mode.  The option value
  17168.      is any combination of the values of `DEFAULT', `BACKUP', `FORCE',
  17169.      or `QUICK'.  If you specify multiple values, separate them by
  17170.      commas.  You can also use a value of `""' to disable this option.
  17171.      If this option is used, `mysqld' will, when it opens a `MyISAM'
  17172.      table, open check whether the table is marked as crashed or wasn't
  17173.      closed properly.  (The last option works only if you are running
  17174.      with `--skip-external-locking'.)  If this is the case, `mysqld'
  17175.      will run a check on the table. If the table was corrupted,
  17176.      `mysqld' will attempt to repair it.
  17177.  
  17178.      The following options affect how the repair works:
  17179.  
  17180.      *Option*   *Description*
  17181.      `DEFAULT'  The same as not giving any option to
  17182.                          `--myisam-recover'.
  17183.      `BACKUP'   If the data file was changed during recovery,
  17184.                 save a                     backup of the
  17185.                 `TBL_NAME.MYD' file as
  17186.                 `TBL_NAME-DATETIME.BAK'.
  17187.      `FORCE'    Run recovery even if we will lose more than
  17188.                 one row                     from the `.MYD'
  17189.                 file.
  17190.      `QUICK'    Don't check the rows in the table if there
  17191.                 aren't any                     delete blocks.
  17192.  
  17193.      Before a table is automatically repaired, MySQL will add a note
  17194.      about this in the error log.  If you want to be able to recover
  17195.      from most problems without user intervention, you should use the
  17196.      options `BACKUP,FORCE'.  This will force a repair of a table even
  17197.      if some rows would be deleted, but it will keep the old data file
  17198.      as a backup so that you can later examine what happened.
  17199.  
  17200.      This option is available as of MySQL 3.23.25.
  17201.  
  17202. `--ndb-connectstring=CONNECT_STRING'
  17203.      When using the `NDB' storage engine, it is possible to point out
  17204.      the management server that distributes the cluster configuration
  17205.      by setting the connect string option.
  17206.  
  17207. `--ndbcluster'
  17208.      If the binary includes support for the `NDB Cluster' storage engine
  17209.      (from version 4.1.3, the MySQL-Max binaries are built with `NDB
  17210.      Cluster' enabled) the default disabling of support for the `NDB
  17211.      Cluster' storage engine can be overruled by using this option.
  17212.      Using the `NDB Cluster' storage engine is necessary for using
  17213.      MySQL Cluster.  *Note NDBCluster::.
  17214.  
  17215. `--new'
  17216.      The `--new' option can be used to make the server behave as 4.1 in
  17217.      certain respects, easing a 4.0 to 4.1 upgrade:
  17218.         * Hexadecimal strings such as `0xFF' are treated as strings by
  17219.           default rather than as numbers.  (Works in 4.0.12 and up.)
  17220.  
  17221.         * `TIMESTAMP' is returned as a string with the format
  17222.           `'YYYY-MM-DD HH:MM:SS''.  (Works in 4.0.13 and up.)  *Note
  17223.           Column types::.
  17224.  
  17225.      This option can be used to help you see how your applications will
  17226.      behave in MySQL 4.1, without actually upgrading to 4.1.
  17227.  
  17228. `--pid-file=PATH'
  17229.      The path to the process ID file used by `mysqld_safe'.
  17230.  
  17231. `--port=PORT_NUM, -P PORT_NUM'
  17232.      The port number to use when listening for TCP/IP connections.
  17233.  
  17234. `--old-protocol, -o'
  17235.      Use the 3.20 protocol for compatibility with some very old clients.
  17236.      *Note Upgrading-from-3.20::.
  17237.  
  17238. `--one-thread'
  17239.      Only use one thread (for debugging under Linux).  This option is
  17240.      available only if the server is built with debugging enabled.
  17241.      *Note Debugging server::.
  17242.  
  17243. `--open-files-limit=COUNT'
  17244.      To change the number of file descriptors available to `mysqld'.
  17245.      If this is not set or set to 0, then `mysqld' will use this value
  17246.      to reserve file descriptors to use with `setrlimit()'.  If this
  17247.      value is 0 then `mysqld' will reserve `max_connections*5' or
  17248.      `max_connections + table_cache*2' (whichever is larger) number of
  17249.      files.  You should try increasing this if `mysqld' gives you the
  17250.      error "Too many open files."
  17251.  
  17252. `--safe-mode'
  17253.      Skip some optimization stages.
  17254.  
  17255. `--safe-show-database'
  17256.      With this option, the `SHOW DATABASES' statement displays only the
  17257.      names of those databases for which the user has some kind of
  17258.      privilege.  As of MySQL 4.0.2, this option is deprecated and
  17259.      doesn't do anything (it is enabled by default), because there is
  17260.      now a `SHOW DATABASES' privilege that can be used to control
  17261.      access to database names on a per-account basis.  *Note Privileges
  17262.      provided::.
  17263.  
  17264. `--safe-user-create'
  17265.      If this is enabled, a user can't create new users with the `GRANT'
  17266.      statement, if the user doesn't have the `INSERT' privilege for the
  17267.      `mysql.user' table or any column in the table.
  17268.  
  17269. `--secure-auth'
  17270.      Disallow authentication for accounts that have old (pre-4.1)
  17271.      passwords.  This option is available as of MySQL 4.1.1.
  17272.  
  17273. `--shared-memory'
  17274.      Enable shared-memory connections by local clients. This option is
  17275.      available only on Windows. It was added in MySQL 4.1.0.
  17276.  
  17277. `--shared-memory-base-name=NAME'
  17278.      The name to use for shared-memory connections.  This option is
  17279.      available only on Windows. It was added in MySQL 4.1.0.
  17280.  
  17281. `--skip-bdb'
  17282.      Disable the `BDB' storage engine. This saves memory and might speed
  17283.      up some operations.  Do not use this option if you require `BDB'
  17284.      tables.
  17285.  
  17286. `--skip-concurrent-insert'
  17287.      Turn off the ability to select and insert at the same time on
  17288.      `MyISAM' tables. (This is to be used only if you think you have
  17289.      found a bug in this feature.)
  17290.  
  17291. `--skip-delay-key-write'
  17292.      Ignore the `DELAY_KEY_WRITE' option for all tables.  As of MySQL
  17293.      4.0.3, you should use `--delay-key-write=OFF' instead.  *Note
  17294.      Server parameters::.
  17295.  
  17296. `--skip-external-locking'
  17297.      Don't use system locking.  To use `isamchk' or `myisamchk', you
  17298.      must shut down the server.  *Note Stability::.  In MySQL 3.23, you
  17299.      can use `CHECK TABLE' and `REPAIR TABLE' to check and repair
  17300.      `MyISAM' tables.  This option previously was named
  17301.      `--skip-locking'.
  17302.  
  17303. `--skip-grant-tables'
  17304.      This option causes the server not to use the privilege system at
  17305.      all. This gives everyone _full access_ to all databases!  (You can
  17306.      tell a running server to start using the grant tables again by
  17307.      executing a `mysqladmin flush-privileges' or `mysqladmin reload'
  17308.      command, or by issuing a `FLUSH PRIVILEGES' statement.)
  17309.  
  17310. `--skip-host-cache'
  17311.      Do not use the internal hostname cache for faster name-to-IP
  17312.      resolution.  Instead, query the DNS server every time a client
  17313.      connects.  *Note DNS::.
  17314.  
  17315. `--skip-innodb'
  17316.      Disable the `InnoDB' storage engine.  This saves memory and disk
  17317.      space and might speed up some operations.  Do not use this option
  17318.      if you require `InnoDB' tables.
  17319.  
  17320. `--skip-isam'
  17321.      Disable the `ISAM' storage engine.  As of MySQL 4.1, `ISAM' is
  17322.      disabled by default, so this option applies only if the server was
  17323.      configured with support for `ISAM'.  This option was added in
  17324.      MySQL 4.1.1.
  17325.  
  17326. `--skip-name-resolve'
  17327.      Do not resolve hostnames when checking client connections. Use
  17328.      only IP numbers. If you use this option, all `Host' column values
  17329.      in the grant tables must be IP numbers or `localhost'.  *Note
  17330.      DNS::.
  17331.  
  17332. `--skip-ndbcluster'
  17333.      Disable the `NDB Cluster' storage engine. This is the default for
  17334.      binaries that were built with `NDB Cluster' storage engine
  17335.      support, this means that the system will only allocate memory and
  17336.      other resources for this storage engine if it is explicitly
  17337.      enabled.
  17338.  
  17339. `--skip-networking'
  17340.      Don't listen for TCP/IP connections at all.  All interaction with
  17341.      `mysqld' must be made via named pipes (on Windows) or Unix socket
  17342.      files (on Unix).  This option is highly recommended for systems
  17343.      where only local clients are allowed.  *Note DNS::.
  17344.  
  17345. `--skip-new'
  17346.      Don't use new, possibly wrong routines.
  17347.  
  17348. `--skip-symlink'
  17349.      This is the old form of `--skip-symbolic-links', for use before
  17350.      MySQL 4.0.13.
  17351.  
  17352. `--symbolic-links, --skip-symbolic-links'
  17353.      Enable or disable symbolic link support. This option has different
  17354.      effects on Windows and Unix:
  17355.  
  17356.         * On Windows, enabling symbolic links allows you to establish a
  17357.           symbolic link to a database directory by creating a
  17358.           `directory.sym' file that contains the path to the real
  17359.           directory.  *Note Windows symbolic links::.
  17360.  
  17361.         * On Unix, enabling symbolic links means that you can link a
  17362.           `MyISAM' index file or data file to another directory with
  17363.           the `INDEX DIRECTORY' or `DATA DIRECTORY' options of the
  17364.           `CREATE TABLE' statement.  If you delete or rename the table,
  17365.           the files that its symbolic links point to also are deleted or
  17366.           renamed. *Note `CREATE TABLE': CREATE TABLE.
  17367.  
  17368.      This option was added in MySQL 4.0.13.
  17369.  
  17370. `--skip-safemalloc'
  17371.      If MySQL is configured with `--with-debug=full', all MySQL programs
  17372.      check for memory overruns during each memory allocation and memory
  17373.      freeing operation.  This checking is very slow, so for the server
  17374.      you can avoid it when you don't need it by using the
  17375.      `--skip-safemalloc' option.
  17376.  
  17377. `--skip-show-database'
  17378.      With this option, the `SHOW DATABASES' statement is allowed only to
  17379.      users who have the `SHOW DATABASES' privilege, and the statement
  17380.      displays all database names.  Without this option, `SHOW
  17381.      DATABASES' is allowed to all users, but displays each database
  17382.      name only if the user has the `SHOW DATABASES' privilege or some
  17383.      privilege for the database.
  17384.  
  17385. `--skip-stack-trace'
  17386.      Don't write stack traces.  This option is useful when you are
  17387.      running `mysqld' under a debugger. On some systems, you also must
  17388.      use this option to get a core file. *Note Debugging server::.
  17389.  
  17390. `--skip-thread-priority'
  17391.      Disable using thread priorities for faster response time.
  17392.  
  17393. `--socket=PATH'
  17394.      On Unix, this option specifies the Unix socket file to use for
  17395.      local connections. The default value is `/tmp/mysql.sock'.  On
  17396.      Windows, the option specifies the pipe name to use for local
  17397.      connections that use a named pipe. The default value is `MySQL'.
  17398.  
  17399. `--sql-mode=VALUE[,VALUE[,VALUE...]]'
  17400.      Set the SQL mode for MySQL. *Note Server SQL mode::. This option
  17401.      was added in 3.23.41.
  17402.  
  17403. `--temp-pool'
  17404.      This option causes most temporary files created by the server to
  17405.      use a small set of names, rather than a unique name for each new
  17406.      file. This works around a problem in the Linux kernel dealing with
  17407.      creating many new files with different names. With the old
  17408.      behavior, Linux seems to "leak" memory, because it's being
  17409.      allocated to the directory entry cache rather than to the disk
  17410.      cache.
  17411.  
  17412. `--transaction-isolation=LEVEL'
  17413.      Sets the default transaction isolation level, which can be
  17414.      `READ-UNCOMMITTED', `READ-COMMITTED', `REPEATABLE-READ', or
  17415.      `SERIALIZABLE'.  *Note `SET TRANSACTION': SET TRANSACTION.
  17416.  
  17417. `--tmpdir=PATH, -t PATH'
  17418.      The path of the directory to use for creating temporary files. It
  17419.      might be useful if your default `/tmp' directory resides on a
  17420.      partition that is too small to hold temporary tables.  Starting
  17421.      from MySQL 4.1, this option accepts several paths that are used in
  17422.      round-robin fashion. Paths should be separated by colon characters
  17423.      (`:') on Unix and semicolon characters (`;') on Windows, NetWare,
  17424.      and OS/2.  If the MySQL server is acting as a replication slave,
  17425.      you should not set `--tmpdir' to point to a directory on a
  17426.      memory-based filesystem or to a directory that is cleared when the
  17427.      server host restarts.  A replication slave needs some of its
  17428.      temporary files to survive a machine restart so that it can
  17429.      replicate temporary tables or `LOAD DATA INFILE' operations. If
  17430.      files in the temporary file directory are lost when the server
  17431.      restarts, replication will fail.
  17432.  
  17433. `--user={USER_NAME | USER_ID}, -u {USER_NAME | USER_ID}'
  17434.      Run the `mysqld' server as the user having the name USER_NAME or
  17435.      the numeric user ID USER_ID.  ("User" in this context refers to a
  17436.      system login account, not a MySQL user listed in the grant tables.)
  17437.  
  17438.      This option is _mandatory_ when starting `mysqld' as `root'.  The
  17439.      server will change its user ID during its startup sequence,
  17440.      causing it to run as that particular user rather than as `root'.
  17441.      *Note Security guidelines::.
  17442.  
  17443.      Starting from MySQL 3.23.56 and 4.0.12: To avoid a possible
  17444.      security hole where a user adds a `--user=root' option to some
  17445.      `my.cnf' file (thus causing the server to run as `root'), `mysqld'
  17446.      uses only the first `--user' option specified and produces a
  17447.      warning if there are multiple `--user' options. Options in
  17448.      `/etc/my.cnf' and `datadir/my.cnf' are processed before
  17449.      command-line options, so it is recommended that you put a `--user'
  17450.      option in `/etc/my.cnf' and specify a value other than `root'. The
  17451.      option in `/etc/my.cnf' will be found before any other `--user'
  17452.      options, which ensures that the server runs as a user other than
  17453.      `root', and that a warning results if any other `--user' option is
  17454.      found.
  17455.  
  17456. `--version, -V'
  17457.      Display version information and exit.
  17458.  
  17459. As of MySQL 4.0, you can assign a value to a server system variable by
  17460. using an option of the form `--VAR_NAME=VALUE'. For example,
  17461. `--key_buffer_size=32M' sets the `key_buffer_size' variable to a value
  17462. of 32MB.
  17463.  
  17464. Note that when setting a variable to a value, MySQL might automatically
  17465. correct it to stay within a given range, or adjust the value to the
  17466. closest allowable value if only certain values are allowed.
  17467.  
  17468. It is also possible to set variables by using
  17469. `--set-variable=VAR_NAME=VALUE' or `-O VAR_NAME=VALUE' syntax. However,
  17470. this syntax is deprecated as of MySQL 4.0.
  17471.  
  17472. You can find a full description for all variables in *Note Server
  17473. system variables::.  The section on tuning server parameters includes
  17474. information on how to optimize them.  *Note Server parameters::.
  17475.  
  17476. You can change the values of most system variables for a running server
  17477. with the `SET' statement. *Note `SET OPTION': SET OPTION.
  17478.  
  17479. If you want to restrict the maximum value that a startup option can be
  17480. set to with `SET', you can define this by using the
  17481. `--maximum-VAR_NAME' command-line option.
  17482.  
  17483. The Server SQL Mode
  17484. -------------------
  17485.  
  17486. The MySQL server can operate in different SQL modes, and (as of MySQL
  17487. 4.1) can apply these modes differentially for different clients. This
  17488. allows an application to tailor server operation to its own
  17489. requirements.
  17490.  
  17491. Modes define what SQL syntax MySQL should support and what kind of data
  17492. validation checks it should perform.  This makes it easier to use MySQL
  17493. in different environments and to use MySQL together with other database
  17494. servers.
  17495.  
  17496. You can set the default SQL mode by starting `mysqld' with the
  17497. `--sql-mode="MODES"' option.  The value also can be empty
  17498. (`--sql-mode=""') if you want to reset it.
  17499.  
  17500. Beginning with MySQL 4.1, you can also change the SQL mode after
  17501. startup time by setting the `sql_mode' variable with a `SET
  17502. [SESSION|GLOBAL] sql_mode='MODES'' statement.  Setting the `GLOBAL'
  17503. variable requires the `SUPER' privilege and affects the operation of
  17504. all clients that connect from that time on. Setting the `SESSION'
  17505. variable affects only the current client.  Any client can change its
  17506. session `sql_mode' value.
  17507.  
  17508. MODES is a list of different modes separated by comma (`,') characters.
  17509. You can retrieve the current mode by issuing a `SELECT @@sql_mode'
  17510. statement. The default value is empty (no modes set).
  17511.  
  17512. The most important `sql_mode' values are probably these:
  17513.  
  17514. `ANSI'
  17515.      Change syntax and behavior to be more conformant to standard SQL.
  17516.      (New in MySQL 4.1.1)
  17517.  
  17518. `STRICT_TRANS_TABLES'
  17519.      If a value could not be inserted as given into a transactional
  17520.      table, abort the statement.  For a non-transactional table, abort
  17521.      the statement if the value occurs in a single-row statement or the
  17522.      first row of a multiple-row statement. More detail is given later
  17523.      in this section.  (New in MySQL 5.0.2)
  17524.  
  17525. `TRADITIONAL'
  17526.      Make MySQL behave like a "traditional" SQL database system.  A
  17527.      simple description of this mode is "give an error instead of a
  17528.      warning" when inserting an incorrect value into a column.  *Note*:
  17529.      The `INSERT'/`UPDATE' will abort as soon as the error is noticed.
  17530.      This may not be what you want if you are using a non-transactional
  17531.      storage engine, because data changes made prior to the error will
  17532.      not be rolled back, resulting in a "partially-done" update.  (New
  17533.      in MySQL 5.0.2)
  17534.  
  17535. When this manual refers to "strict mode," it means a mode where at least
  17536. one of `STRICT_TRANS_TABLES' or `STRICT_ALL_TABLES' is enabled.
  17537.  
  17538. The following list describes all the supported modes:
  17539.  
  17540. `ALLOW_INVALID_DATES'
  17541.      Don't do full checking of dates in strict mode. Check only that
  17542.      the month is in the range from 1 to 12 and the day is in the range
  17543.      from 1 to 31. This is very convenient for Web applications where
  17544.      you obtain year, month, and day in three different fields and you
  17545.      want to store exactly what the user inserted (without date
  17546.      validation).  This mode applies to `DATE' and `DATETIME' columns.
  17547.      It does not apply `TIMESTAMP' columns, which always require a
  17548.      valid date.
  17549.  
  17550.      This mode is new in MySQL 5.0.2. Before 5.0.2, this was the
  17551.      default MySQL date-handling mode. As of 5.0.2, enabling strict
  17552.      mode causes the server to require that month and day values be
  17553.      legal, not just in the range from 1 to 12 and 1 to 31. For
  17554.      example, `'2004-04-31'' is legal with strict mode disabled, but
  17555.      illegal with strict mode enabled. To allow such dates in strict
  17556.      mode, enable `ALLOW_INVALID_DATES' as well.
  17557.  
  17558. `ANSI_QUOTES'
  17559.      Treat `"' as an identifier quote character (like the ``' quote
  17560.      character) and not as a string quote character. You can still use
  17561.      ``' to quote identifers in ANSI mode. With `ANSI_QUOTES' enabled,
  17562.      you cannot use double quotes to quote a literal string, because it
  17563.      will be interpreted as an identifier.  (New in MySQL 4.0.0)
  17564.  
  17565. `ERROR_FOR_DIVISION_BY_ZERO'
  17566.      Produce an error in strict mode (otherwise a warning) when we
  17567.      encounter a division by zero (or `MOD(X,0)') during an `INSERT'/
  17568.      `UPDATE'. If this mode is not given, MySQL instead returns `NULL'
  17569.      for divisions by zero.  If used with `IGNORE', MySQL generates a
  17570.      warning for divisions by zero, but the result of the operation is
  17571.      `NULL'.  (New in MySQL 5.0.2)
  17572.  
  17573. `IGNORE_SPACE'
  17574.      Allow spaces between a function name and the `(' character.  This
  17575.      forces all function names to be treated as reserved words. As a
  17576.      result, if you want to access any database, table, or column name
  17577.      that is a reserved word, you must quote it.  For example, because
  17578.      there is a `USER()' function, the name of the `user' table in the
  17579.      `mysql' database and the `User' column in that table become
  17580.      reserved, so you must quote them:
  17581.  
  17582.           SELECT "User" FROM mysql."user";
  17583.  
  17584.      (New in MySQL 4.0.0)
  17585.  
  17586. `NO_AUTO_VALUE_ON_ZERO'
  17587.      `NO_AUTO_VALUE_ON_ZERO' affects handling of `AUTO_INCREMENT'
  17588.      columns. Normally, you generate the next sequence number for the
  17589.      column by inserting either `NULL' or `0' into it.
  17590.      `NO_AUTO_VALUE_ON_ZERO' suppresses this behavior for `0' so that
  17591.      only `NULL' generates the next sequence number.  (New in MySQL
  17592.      4.1.1)
  17593.  
  17594.      This mode can be useful if `0' has been stored in a table's
  17595.      `AUTO_INCREMENT' column. (This is not a recommended practice, by
  17596.      the way.)  For example, if you dump the table with `mysqldump' and
  17597.      then reload it, MySQL normally generates new sequence numbers when
  17598.      it encounters the `0' values, resulting in a table with different
  17599.      contents than the one that was dumped. Enabling
  17600.      `NO_AUTO_VALUE_ON_ZERO' before reloading the dump file solves this
  17601.      problem. As of MySQL 4.1.1, `mysqldump' automatically includes a
  17602.      statement in the dump output to enable `NO_AUTO_VALUE_ON_ZERO'.
  17603.  
  17604. `NO_DIR_IN_CREATE'
  17605.      When creating a table, ignore all `INDEX DIRECTORY' and `DATA
  17606.      DIRECTORY' directives. This option is useful on slave replication
  17607.      servers.  (New in MySQL 4.0.15)
  17608.  
  17609. `NO_FIELD_OPTIONS'
  17610.      Don't print MySQL-specific column options in the output of `SHOW
  17611.      CREATE TABLE'. This mode is used by `mysqldump' in portability
  17612.      mode.  (New in MySQL 4.1.1)
  17613.  
  17614. `NO_KEY_OPTIONS'
  17615.      Don't print MySQL-specific index options in the output of `SHOW
  17616.      CREATE TABLE'. This mode is used by `mysqldump' in portability
  17617.      mode.  (New in MySQL 4.1.1)
  17618.  
  17619. `NO_TABLE_OPTIONS'
  17620.      Don't print MySQL-specific table options (such as `ENGINE') in the
  17621.      output of `SHOW CREATE TABLE'. This mode is used by `mysqldump' in
  17622.      portability mode.  (New in MySQL 4.1.1)
  17623.  
  17624. `NO_ZERO_DATE'
  17625.      Don't allow `'0000-00-00'' as a valid date. You can still insert
  17626.      zero dates with the `IGNORE' option.  (New in MySQL 5.0.2)
  17627.  
  17628. `NO_ZERO_IN_DATE'
  17629.      Don't accept dates where the month or day part is 0. If used with
  17630.      the `IGNORE' option, we insert a `'0000-00-00'' date for any such
  17631.      date.  (New in MySQL 5.0.2)
  17632.  
  17633. `NO_UNSIGNED_SUBTRACTION'
  17634.      In subtraction operations, don't mark the result as `UNSIGNED' if
  17635.      one of the operands is unsigned. Note that this makes `UNSIGNED
  17636.      BIGINT' not 100% usable in all contexts. *Note Cast Functions::.
  17637.      (New in MySQL 4.0.2)
  17638.  
  17639. `ONLY_FULL_GROUP_BY'
  17640.      Don't allow queries that in the `GROUP BY' part refer to a not
  17641.      selected column.  (New in MySQL 4.0.0)
  17642.  
  17643. `PIPES_AS_CONCAT'
  17644.      Treat `||' as a string concatenation operator (same as `CONCAT()')
  17645.      rather than as a synonym for `OR'.  (New in MySQL 4.0.0)
  17646.  
  17647. `REAL_AS_FLOAT'
  17648.      Treat `REAL' as a synonym for `FLOAT' rather than as a synonym for
  17649.      `DOUBLE'.  (New in MySQL 4.0.0)
  17650.  
  17651. `STRICT_ALL_TABLES'
  17652.      Enable strict mode for all storage engines.  Invalid data values
  17653.      are rejected.  Additional detail follows.  (New in MySQL 5.0.2)
  17654.  
  17655. `STRICT_TRANS_TABLES'
  17656.      Enable strict mode for transactional storage engines, and when
  17657.      possible for non-transactional storage engines.  Additional detail
  17658.      follows.  (New in MySQL 5.0.2)
  17659.  
  17660. Strict mode controls how MySQL handles values that are invalid or
  17661. missing. A value can be invalid for several reasons.  For example, it
  17662. might have the wrong data type for the column, or it might be out of
  17663. range. A value is missing when a new row to be inserted does not
  17664. contain a value for a column that has no explicit `DEFAULT' clause in
  17665. its definition.
  17666.  
  17667. For transactional tables, an error occurs for invalid or missing values
  17668. in a statement when either of the `STRICT_ALL_TABLES' or
  17669. `STRICT_TRANS_TABLES' modes are enabled.  The statement is aborted and
  17670. rolled back.
  17671.  
  17672. For non-transactional tables, the behavior is the same for either mode,
  17673. if the bad value occurs in the first row to be inserted or updated.
  17674. The statement is aborted and the table remains unchanged.  If the
  17675. statement inserts or modifies multiple rows and the bad value occurs in
  17676. the second or later row, the result depends on which strict option is
  17677. enabled:
  17678.  
  17679.    * For `STRICT_ALL_TABLES', MySQL returns an error and ignores the
  17680.      rest of the rows. However, in this case, the earlier rows will
  17681.      already have been inserted or updated.  This means that you might
  17682.      get a partial update, which might not be what you want.  To avoid
  17683.      this, it's best to use single-row statements because these can be
  17684.      aborted without changing the table.
  17685.  
  17686.    * For `STRICT_TRANS_TABLES', MySQL converts an invalid value to the
  17687.      closest valid value for the column and insert the adjusted value.
  17688.      If a value is missing, MySQL inserts the implicit default value
  17689.      for the column data type.  In either case, MySQL generates a
  17690.      warning rather than an error and continues processing the
  17691.      statement. Implicit defaults are described in *Note `CREATE
  17692.      TABLE': CREATE TABLE.
  17693.  
  17694.  
  17695. Strict mode disallows invalid date values such as `'2004-04-31''.  It
  17696. does not disallow dates with zero parts such as `2004-04-00'' or "zero"
  17697. dates. To disallow these as well, enable the `NO_ZERO_IN_DATE' and
  17698. `NO_ZERO_DATE' SQL modes in addition to strict mode.
  17699.  
  17700. If you are not using strict mode (that is, neither `STRICT_TRANS_TABLES'
  17701. nor `STRICT_ALL_TABLES' is enabled), MySQL inserts adjusted values for
  17702. invalid or missing values and produces warnings.  In strict mode, you
  17703. can produce this behavior by using `INSERT IGNORE' or `UPDATE IGNORE'.
  17704. *Note `SHOW WARNINGS': SHOW WARNINGS.
  17705.  
  17706. The following special modes are provided as shorthand for combinations
  17707. of mode values from the preceding list.  All are available as of MySQL
  17708. 4.1.1, except `TRADITIONAL' (5.0.2).
  17709.  
  17710. `ANSI'
  17711.      Equivalent to `REAL_AS_FLOAT', `PIPES_AS_CONCAT', `ANSI_QUOTES',
  17712.      `IGNORE_SPACE', `ONLY_FULL_GROUP_BY'. *Note ANSI mode::.
  17713.  
  17714. `DB2'
  17715.      Equivalent to `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE',
  17716.      `NO_KEY_OPTIONS', `NO_TABLE_OPTIONS', `NO_FIELD_OPTIONS'.
  17717.  
  17718. `MAXDB'
  17719.      Equivalent to `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE',
  17720.      `NO_KEY_OPTIONS', `NO_TABLE_OPTIONS', `NO_FIELD_OPTIONS'.
  17721.  
  17722. `MSSQL'
  17723.      Equivalent to `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE',
  17724.      `NO_KEY_OPTIONS', `NO_TABLE_OPTIONS', `NO_FIELD_OPTIONS'.
  17725.  
  17726. `MYSQL323'
  17727.      Equivalent to `NO_FIELD_OPTIONS'.
  17728.  
  17729. `MYSQL40'
  17730.      Equivalent to `NO_FIELD_OPTIONS'.
  17731.  
  17732. `ORACLE'
  17733.      Equivalent to `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE',
  17734.      `NO_KEY_OPTIONS', `NO_TABLE_OPTIONS', `NO_FIELD_OPTIONS'.
  17735.  
  17736. `POSTGRESQL'
  17737.      Equivalent to `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE',
  17738.      `NO_KEY_OPTIONS', `NO_TABLE_OPTIONS', `NO_FIELD_OPTIONS'.
  17739.  
  17740. `TRADITIONAL'
  17741.      Equivalent to `STRICT_TRANS_TABLES', `STRICT_ALL_TABLES',
  17742.      `NO_ZERO_IN_DATE', `NO_ZERO_DATE', `ERROR_FOR_DIVISION_BY_ZERO'.
  17743.  
  17744. Server System Variables
  17745. -----------------------
  17746.  
  17747. The server maintains many system variables that indicate how it is
  17748. configured.  All of them have default values. They can be set at server
  17749. startup using options on the command line or in option files. Most of
  17750. them can be set at runtime using the `SET' statement.
  17751.  
  17752. Beginning with MySQL 4.0.3, the `mysqld' server maintains two kinds of
  17753. variables.  Global variables affect the overall operation of the server.
  17754. Session variables affect its operation for individual client
  17755. connections.
  17756.  
  17757. When the server starts, it initializes all global variables to their
  17758. default values. These defaults can be changed by options specified in
  17759. option files or on the command line.  After the server starts, those
  17760. global variables that are dynamic can be changed by connecting to the
  17761. server and issuing a `SET GLOBAL VAR_NAME' statement. To change a
  17762. global variable, you must have the `SUPER' privilege.
  17763.  
  17764. The server also maintains a set of session variables for each client
  17765. that connects. The client's session variables are initialized at connect
  17766. time using the current values of the corresponding global variables. For
  17767. those session variables that are dynamic, the client can change them by
  17768. issuing a `SET SESSION VAR_NAME' statement. Setting a session variable
  17769. requires no special privilege, but a client can change only its own
  17770. session variables, not those of any other client.
  17771.  
  17772. A change to a global variable is visible to any client that accesses
  17773. that global variable. However, it affects the corresponding session
  17774. variable that is initialized from the global variable only for clients
  17775. that connect after the change.  It does not affect the session variable
  17776. for any client that is already connected (not even that of the client
  17777. that issues the `SET GLOBAL' statement).
  17778.  
  17779. When setting a variable using a startup option, variable values can be
  17780. given with a suffix of `K', `M', or `G' to indicate kilobytes,
  17781. megabytes, or gigabytes, respectively. For example, the following
  17782. command starts the server with a key buffer size of 16 megabytes:
  17783.  
  17784.      mysqld --key_buffer_size=16M
  17785.  
  17786. Before MySQL 4.0, use this syntax instead:
  17787.  
  17788.      mysqld --set-variable=key_buffer_size=16M
  17789.  
  17790. The lettercase of suffix letters does not matter; `16M' and `16m' are
  17791. equivalent.
  17792.  
  17793. At runtime, use the `SET' statement to set system variables. In this
  17794. context, suffix letters cannot be used, but the value can take the form
  17795. of an expression:
  17796.  
  17797.      mysql> SET sort_buffer_size = 10 * 1024 * 1024;
  17798.  
  17799. To specify explicitly whether to set the global or session variable,
  17800. use the `GLOBAL' or `SESSION' options:
  17801.  
  17802.      mysql> SET GLOBAL sort_buffer_size = 10 * 1024 * 1024;
  17803.      mysql> SET SESSION sort_buffer_size = 10 * 1024 * 1024;
  17804.  
  17805. Without either option, the statement sets the session variable.
  17806.  
  17807. The variables that can be set at runtime are listed in *Note Dynamic
  17808. System Variables::.
  17809.  
  17810. If you want to restrict the maximum value to which a system variable can
  17811. be set with the `SET' statement, you can specify this maximum by using
  17812. an option of the form `--maximum-VAR_NAME' at server startup. For
  17813. example, to prevent the value of `query_cache_size' from being
  17814. increased to more than 32MB at runtime, use the option
  17815. `--maximum-query_cache_size=32M'. This feature is available as of MySQL
  17816. 4.0.2.
  17817.  
  17818. You can view system variables and their values by using the `SHOW
  17819. VARIABLES' statement.  See *Note System Variables:: for more
  17820. information.
  17821.  
  17822.      mysql> SHOW VARIABLES;
  17823.      +---------------------------------+------------------------------+
  17824.      | Variable_name                   | Value                        |
  17825.      +---------------------------------+------------------------------|
  17826.      | back_log                        | 50                           |
  17827.      | basedir                         | /usr/local/mysql             |
  17828.      | bdb_cache_size                  | 8388572                      |
  17829.      | bdb_home                        | /usr/local/mysql             |
  17830.      | bdb_log_buffer_size             | 32768                        |
  17831.      | bdb_logdir                      |                              |
  17832.      | bdb_max_lock                    | 10000                        |
  17833.      | bdb_shared_data                 | OFF                          |
  17834.      | bdb_tmpdir                      | /tmp/                        |
  17835.      | bdb_version                     | Sleepycat Software: ...      |
  17836.      | binlog_cache_size               | 32768                        |
  17837.      | bulk_insert_buffer_size         | 8388608                      |
  17838.      | character_set                   | latin1                       |
  17839.      | character_sets                  | latin1 big5 czech euc_kr     |
  17840.      | concurrent_insert               | ON                           |
  17841.      | connect_timeout                 | 5                            |
  17842.      | convert_character_set           |                              |
  17843.      | datadir                         | /usr/local/mysql/data/       |
  17844.      | default_week_format             | 0                            |
  17845.      | delay_key_write                 | ON                           |
  17846.      | delayed_insert_limit            | 100                          |
  17847.      | delayed_insert_timeout          | 300                          |
  17848.      | delayed_queue_size              | 1000                         |
  17849.      | flush                           | OFF                          |
  17850.      | flush_time                      | 0                            |
  17851.      | ft_boolean_syntax               | + -><()~*:""&|               |
  17852.      | ft_max_word_len                 | 84                           |
  17853.      | ft_min_word_len                 | 4                            |
  17854.      | ft_query_expansion_limit        | 20                           |
  17855.      | ft_stopword_file                | (built-in)                   |
  17856.      | have_bdb                        | YES                          |
  17857.      | have_innodb                     | YES                          |
  17858.      | have_isam                       | YES                          |
  17859.      | have_openssl                    | YES                          |
  17860.      | have_query_cache                | YES                          |
  17861.      | have_raid                       | NO                           |
  17862.      | have_symlink                    | DISABLED                     |
  17863.      | init_file                       |                              |
  17864.      | innodb_additional_mem_pool_size | 1048576                      |
  17865.      | innodb_buffer_pool_size         | 8388608                      |
  17866.      | innodb_data_file_path           | ibdata1:10M:autoextend       |
  17867.      | innodb_data_home_dir            |                              |
  17868.      | innodb_fast_shutdown            | ON                           |
  17869.      | innodb_file_io_threads          | 4                            |
  17870.      | innodb_flush_log_at_trx_commit  | 1                            |
  17871.      | innodb_flush_method             |                              |
  17872.      | innodb_force_recovery           | 0                            |
  17873.      | innodb_lock_wait_timeout        | 50                           |
  17874.      | innodb_log_arch_dir             |                              |
  17875.      | innodb_log_archive              | OFF                          |
  17876.      | innodb_log_buffer_size          | 1048576                      |
  17877.      | innodb_log_file_size            | 5242880                      |
  17878.      | innodb_log_files_in_group       | 2                            |
  17879.      | innodb_log_group_home_dir       | ./                           |
  17880.      | innodb_mirrored_log_groups      | 1                            |
  17881.      | innodb_thread_concurrency       | 8                            |
  17882.      | interactive_timeout             | 28800                        |
  17883.      | join_buffer_size                | 131072                       |
  17884.      | key_buffer_size                 | 16773120                     |
  17885.      | key_cache_age_threshold         | 300                          |
  17886.      | key_cache_block_size            | 1024                         |
  17887.      | key_cache_division_limit        | 100                          |
  17888.      | language                        | /usr/local/mysql/share/...   |
  17889.      | large_files_support             | ON                           |
  17890.      | local_infile                    | ON                           |
  17891.      | locked_in_memory                | OFF                          |
  17892.      | log                             | OFF                          |
  17893.      | log_bin                         | OFF                          |
  17894.      | log_slave_updates               | OFF                          |
  17895.      | log_slow_queries                | OFF                          |
  17896.      | log_update                      | OFF                          |
  17897.      | log_warnings                    | 1                            |
  17898.      | long_query_time                 | 10                           |
  17899.      | low_priority_updates            | OFF                          |
  17900.      | lower_case_table_names          | 0                            |
  17901.      | max_allowed_packet              | 1047552                      |
  17902.      | max_binlog_cache_size           | 4294967295                   |
  17903.      | max_binlog_size                 | 1073741824                   |
  17904.      | max_connect_errors              | 10                           |
  17905.      | max_connections                 | 100                          |
  17906.      | max_delayed_threads             | 20                           |
  17907.      | max_error_count                 | 64                           |
  17908.      | max_heap_table_size             | 16777216                     |
  17909.      | max_join_size                   | 4294967295                   |
  17910.      | max_relay_log_size              | 0                            |
  17911.      | max_sort_length                 | 1024                         |
  17912.      | max_tmp_tables                  | 32                           |
  17913.      | max_user_connections            | 0                            |
  17914.      | max_write_lock_count            | 4294967295                   |
  17915.      | myisam_max_extra_sort_file_size | 268435456                    |
  17916.      | myisam_max_sort_file_size       | 2147483647                   |
  17917.      | myisam_recover_options          | force                        |
  17918.      | myisam_repair_threads           | 1                            |
  17919.      | myisam_sort_buffer_size         | 8388608                      |
  17920.      | net_buffer_length               | 16384                        |
  17921.      | net_read_timeout                | 30                           |
  17922.      | net_retry_count                 | 10                           |
  17923.      | net_write_timeout               | 60                           |
  17924.      | open_files_limit                | 1024                         |
  17925.      | pid_file                        | /usr/local/mysql/name.pid    |
  17926.      | port                            | 3306                         |
  17927.      | protocol_version                | 10                           |
  17928.      | query_cache_limit               | 1048576                      |
  17929.      | query_cache_size                | 0                            |
  17930.      | query_cache_type                | ON                           |
  17931.      | read_buffer_size                | 131072                       |
  17932.      | read_rnd_buffer_size            | 262144                       |
  17933.      | rpl_recovery_rank               | 0                            |
  17934.      | server_id                       | 0                            |
  17935.      | skip_external_locking           | ON                           |
  17936.      | skip_networking                 | OFF                          |
  17937.      | skip_show_database              | OFF                          |
  17938.      | slave_net_timeout               | 3600                         |
  17939.      | slow_launch_time                | 2                            |
  17940.      | socket                          | /tmp/mysql.sock              |
  17941.      | sort_buffer_size                | 2097116                      |
  17942.      | sql_mode                        |                              |
  17943.      | table_cache                     | 64                           |
  17944.      | table_type                      | MYISAM                       |
  17945.      | thread_cache_size               | 3                            |
  17946.      | thread_stack                    | 131072                       |
  17947.      | timezone                        | EEST                         |
  17948.      | tmp_table_size                  | 33554432                     |
  17949.      | tmpdir                          | /tmp/:/mnt/hd2/tmp/          |
  17950.      | tx_isolation                    | READ-COMMITTED               |
  17951.      | version                         | 4.0.4-beta                   |
  17952.      | wait_timeout                    | 28800                        |
  17953.      +---------------------------------+------------------------------+
  17954.  
  17955. Most system variables are described here.  Variables with no version
  17956. indicated have been present since at least MySQL 3.22.  `InnoDB' system
  17957. variables are listed at *Note `InnoDB' start: InnoDB start.
  17958.  
  17959. Values for buffer sizes, lengths, and stack sizes are given in bytes
  17960. unless otherwise specified.
  17961.  
  17962. Information on tuning these variables can be found in *Note Server
  17963. parameters::.
  17964.  
  17965. `ansi_mode'
  17966.      This is `ON' if `mysqld' was started with `--ansi'.  *Note ANSI
  17967.      mode::.  This variable was added in MySQL 3.23.6 and removed in
  17968.      3.23.41.  See the description for `sql_mode'.
  17969.  
  17970. `back_log'
  17971.      The number of outstanding connection requests MySQL can have. This
  17972.      comes into play when the main MySQL thread gets very many
  17973.      connection requests in a very short time. It then takes some time
  17974.      (although very little) for the main thread to check the connection
  17975.      and start a new thread. The `back_log' value indicates how many
  17976.      requests can be stacked during this short time before MySQL
  17977.      momentarily stops answering new requests. You need to increase
  17978.      this only if you expect a large number of connections in a short
  17979.      period of time.
  17980.  
  17981.      In other words, this value is the size of the listen queue for
  17982.      incoming TCP/IP connections.  Your operating system has its own
  17983.      limit on the size of this queue.  The manual page for the Unix
  17984.      `listen()' system call should have more details.  Check your OS
  17985.      documentation for the maximum value for this variable.  Attempting
  17986.      to set `back_log' higher than your operating system limit will be
  17987.      ineffective.
  17988.  
  17989. `basedir'
  17990.      The MySQL installation base directory. This variable can be set
  17991.      with the `--basedir' option.
  17992.  
  17993. `bdb_cache_size'
  17994.      The size of the buffer that is allocated for caching indexes and
  17995.      rows for `BDB' tables.  If you don't use `BDB' tables, you should
  17996.      start `mysqld' with `--skip-bdb' to not waste memory for this
  17997.      cache.  This variable was added in MySQL 3.23.14.
  17998.  
  17999. `bdb_home'
  18000.      The base directory for `BDB' tables.  This should be assigned the
  18001.      same value as the `datadir' variable.  This variable was added in
  18002.      MySQL 3.23.14.
  18003.  
  18004. `bdb_log_buffer_size'
  18005.      The size of the buffer that is allocated for caching indexes and
  18006.      rows for `BDB' tables.  If you don't use `BDB' tables, you should
  18007.      set this to 0 or start `mysqld' with `--skip-bdb' to not waste
  18008.      memory for this cache.  This variable was added in MySQL 3.23.31.
  18009.  
  18010. `bdb_logdir'
  18011.      The directory where the `BDB' storage engine writes its log files.
  18012.      This variable can be set with the `--bdb-logdir' option.  This
  18013.      variable was added in MySQL 3.23.14.
  18014.  
  18015. `bdb_max_lock'
  18016.      The maximum number of locks you can have active on a `BDB' table
  18017.      (10,000 by default). You should increase this if errors such as the
  18018.      following occur when you perform long transactions or when
  18019.      `mysqld' has to examine many rows to calculate a query:
  18020.  
  18021.           bdb: Lock table is out of available locks
  18022.           Got error 12 from ...
  18023.  
  18024.      This variable was added in MySQL 3.23.29.
  18025.  
  18026. `bdb_shared_data'
  18027.      This is `ON' if you are using `--bdb-shared-data'.  This variable
  18028.      was added in MySQL 3.23.29.
  18029.  
  18030. `bdb_tmpdir'
  18031.      The value of the `--bdb-tmpdir' option.  This variable was added
  18032.      in MySQL 3.23.14.
  18033.  
  18034. `bdb_version'
  18035.      See the description for `version_bdb'.
  18036.  
  18037. `binlog_cache_size'
  18038.      The size of the cache to hold the SQL statements for the binary
  18039.      log during a transaction.  A binary log cache is allocated for
  18040.      each client if the server supports any transactional storage
  18041.      engines and, starting from MySQL 4.1.2, if the server has binary
  18042.      log enabled (`--log-bin' option). If you often use big,
  18043.      multiple-statement transactions, you can increase this to get more
  18044.      performance.  The `Binlog_cache_use' and `Binlog_cache_disk_use'
  18045.      status variables can be useful for tuning the size of this
  18046.      variable.  This variable was added in MySQL 3.23.29.  *Note Binary
  18047.      log::.
  18048.  
  18049. `bulk_insert_buffer_size'
  18050.      `MyISAM' uses a special tree-like cache to make bulk inserts
  18051.      faster for `INSERT ... SELECT', `INSERT ... VALUES (...), (...),
  18052.      ...', and `LOAD DATA INFILE'. This variable limits the size of the
  18053.      cache tree in bytes per thread. Setting it to 0 disables this
  18054.      optimization.  *Note*: This cache is used only when adding data to
  18055.      a non-empty table.  The default value is 8MB.  This variable was
  18056.      added in MySQL 4.0.3.  This variable previously was named
  18057.      `myisam_bulk_insert_tree_size'.
  18058.  
  18059. `character_set'
  18060.      The default character set.  This variable was added in MySQL
  18061.      3.23.3, then removed in MySQL 4.1.1 and replaced by the various
  18062.      `character_set_XXX' variables.
  18063.  
  18064. `character_set_client'
  18065.      The character set for statements that arrive from the client.
  18066.      This variable was added in MySQL 4.1.1.
  18067.  
  18068. `character_set_connection'
  18069.      The character set used for literals that do not have a character
  18070.      set introducer and for number-to-string conversion.  This variable
  18071.      was added in MySQL 4.1.1.
  18072.  
  18073. `character_set_database'
  18074.      The character set used by the default database.  The server sets
  18075.      this variable whenever the default database changes.  If there is
  18076.      no default database, the variable has the same value as
  18077.      `character_set_server'.  This variable was added in MySQL 4.1.1.
  18078.  
  18079. `character_set_results'
  18080.      The character set used for returning query results to the client.
  18081.      This variable was added in MySQL 4.1.1.
  18082.  
  18083. `character_set_server'
  18084.      The server default character set.  This variable was added in
  18085.      MySQL 4.1.1.
  18086.  
  18087. `character_set_system'
  18088.      The character set used by the server for storing identifiers.  The
  18089.      value is always `utf8'.  This variable was added in MySQL 4.1.1.
  18090.  
  18091. `character_sets'
  18092.      The supported character sets.  This variable was added in MySQL
  18093.      3.23.15 and removed in MySQL 4.1.1.  (Use `SHOW CHARACTER SET' for
  18094.      a list of character sets.)
  18095.  
  18096. `character_sets_dir'
  18097.      The directory where character sets are installed.  This variable
  18098.      was added in MySQL 4.1.2.
  18099.  
  18100. `collation_connection'
  18101.      The collation of the connection character set.  This variable was
  18102.      added in MySQL 4.1.1.
  18103.  
  18104. `collation_database'
  18105.      The collation used by the default database.  The server sets this
  18106.      variable whenever the default database changes.  If there is no
  18107.      default database, the variable has the same value as
  18108.      `collation_server'.  This variable was added in MySQL 4.1.1.
  18109.  
  18110. `collation_server'
  18111.      The server default collation.  This variable was added in MySQL
  18112.      4.1.1.
  18113.  
  18114. `concurrent_insert'
  18115.      If `ON' (the default), MySQL allows `INSERT' and `SELECT'
  18116.      statements to run concurrently for `MyISAM' tables that have no
  18117.      free blocks in the middle.  You can turn this option off by
  18118.      starting `mysqld' with `--safe' or `--skip-new'.  This variable
  18119.      was added in MySQL 3.23.7.
  18120.  
  18121. `connect_timeout'
  18122.      The number of seconds the `mysqld' server waits for a connect
  18123.      packet before responding with `Bad handshake'.
  18124.  
  18125. `convert_character_set'
  18126.      The current character set mapping that was set by `SET CHARACTER
  18127.      SET'.  This variable was removed in MySQL 4.1.
  18128.  
  18129. `datadir'
  18130.      The MySQL data directory. This variable can be set with the
  18131.      `--datadir' option.
  18132.  
  18133. `default_week_format'
  18134.      The default mode value to use for the `WEEK()' function.  This
  18135.      variable is available as of MySQL 4.0.14.
  18136.  
  18137. `delay_key_write'
  18138.      This option applies only to `MyISAM' tables. It can have one of the
  18139.      following values to affect handling of the `DELAY_KEY_WRITE' table
  18140.      option that can be used in `CREATE TABLE' statements.
  18141.  
  18142.      *Option**Description*
  18143.      `OFF'   `DELAYED_KEY_WRITE' is ignored.
  18144.      `ON'    MySQL honors the `DELAY_KEY_WRITE' option for
  18145.              `CREATE TABLE'. This is the default value.
  18146.      `ALL'   All new opened tables are treated as if they were
  18147.              created with the `DELAY_KEY_WRITE' option enabled.
  18148.  
  18149.      If `DELAY_KEY_WRITE' is enabled, this means that the key buffer for
  18150.      tables with this option are not flushed on every index update, but
  18151.      only when a table is closed.  This will speed up writes on keys a
  18152.      lot, but if you use this feature, you should add automatic
  18153.      checking of all `MyISAM' tables by starting the server with the
  18154.      `--myisam-recover' option (for example,
  18155.      `--myisam-recover=BACKUP,FORCE').  See *Note Server options:: and
  18156.      *Note MyISAM start::.
  18157.  
  18158.      Note that `--external-locking' doesn't offer any protection against
  18159.      index corruption for tables that use delayed key writes.
  18160.  
  18161.      This variable was added in MySQL 3.23.8.
  18162.  
  18163. `delayed_insert_limit'
  18164.      After inserting `delayed_insert_limit' delayed rows, the `INSERT
  18165.      DELAYED' handler thread checks whether there are any `SELECT'
  18166.      statements pending. If so, it allows them to execute before
  18167.      continuing to insert delayed rows.
  18168.  
  18169. `delayed_insert_timeout'
  18170.      How long an `INSERT DELAYED' handler thread should wait for
  18171.      `INSERT' statements before terminating.
  18172.  
  18173. `delayed_queue_size'
  18174.      This is a per-table limit on the number of rows to queue when
  18175.      handling `INSERT DELAYED' statements.  If the queue becomes full,
  18176.      any client that issues an `INSERT DELAYED' statement will wait
  18177.      until there is room in the queue again.
  18178.  
  18179. `expire_logs_days'
  18180.      The number of days for automatic binary log removal.  The default
  18181.      is 0, which means "no automatic removal."  This variable was added
  18182.      in MySQL 4.1.0.
  18183.  
  18184. `flush'
  18185.      This is `ON' if you have started `mysqld' with the `--flush'
  18186.      option.  This variable was added in MySQL 3.22.9.
  18187.  
  18188. `flush_time'
  18189.      If this is set to a non-zero value, all tables will be closed every
  18190.      `flush_time' seconds to free up resources and sync unflushed data
  18191.      to disk.  We recommend this option only on Windows 9x or Me, or on
  18192.      systems with minimal resources available.  This variable was added
  18193.      in MySQL 3.22.18.
  18194.  
  18195. `ft_boolean_syntax'
  18196.      The list of operators supported by boolean full-text searches
  18197.      performed using `IN BOOLEAN MODE'.  This variable was added in
  18198.      MySQL 4.0.1.  *Note Fulltext Boolean::.
  18199.  
  18200.      The default variable value is `'+ -><()~*:""&|''. The rules for
  18201.      changing the value are as follows:
  18202.  
  18203.         * Operator function is determined by position within the string.
  18204.  
  18205.         * The replacement value must be 14 characters.
  18206.  
  18207.         * Each character must be an ASCII non-alphanumeric character.
  18208.  
  18209.         * Either the first or second character must be a space.
  18210.  
  18211.         * No duplicates are allowed except the phrase quoting operators
  18212.           in positions 11 and 12. These two characters are not required
  18213.           to be the same, but they are the only two that may be.
  18214.  
  18215.         * Positions 10, 13, and 14 (which by default are set to `:',
  18216.           `&', and `|') are reserved for future extensions.
  18217.  
  18218.  
  18219. `ft_max_word_len'
  18220.      The maximum length of the word to be included in a `FULLTEXT'
  18221.      index.  This variable was added in MySQL 4.0.0.
  18222.  
  18223.      *Note*: `FULLTEXT' indexes must be rebuilt after changing this
  18224.      variable.  Use `REPAIR TABLE TBL_NAME QUICK'.
  18225.  
  18226. `ft_min_word_len'
  18227.      The minimum length of the word to be included in a `FULLTEXT'
  18228.      index.  This variable was added in MySQL 4.0.0.
  18229.  
  18230.      *Note*: `FULLTEXT' indexes must be rebuilt after changing this
  18231.      variable.  Use `REPAIR TABLE TBL_NAME QUICK'.
  18232.  
  18233. `ft_query_expansion_limit'
  18234.      The number of top matches to use for full-text searches performed
  18235.      using `WITH QUERY EXPANSION'.  This variable was added in MySQL
  18236.      4.1.1.
  18237.  
  18238. `ft_stopword_file'
  18239.      The file from which to read the list of stopwords for full-text
  18240.      searches.  All the words from the file are used; comments are
  18241.      _not_ honored.  By default, a built-in list of stopwords is used
  18242.      (as defined in the `myisam/ft_static.c' file).  Setting this
  18243.      variable to the empty string (`''') disables stopword filtering.
  18244.      This variable was added in MySQL 4.0.10.
  18245.  
  18246.      *Note*: `FULLTEXT' indexes must be rebuilt after changing this
  18247.      variable.  Use `REPAIR TABLE TBL_NAME QUICK'.
  18248.  
  18249. `group_concat_max_len'
  18250.      The maximum allowed result length for the `GROUP_CONCAT()'
  18251.      function.  This variable was added in MySQL 4.1.0.
  18252.  
  18253. `have_archive'
  18254.      `YES' if `mysqld' supports `ARCHIVE' tables.  This variable was
  18255.      added in MySQL 4.1.3.
  18256.  
  18257. `have_bdb'
  18258.      `YES' if `mysqld' supports `BDB' tables. `DISABLED' if
  18259.      `--skip-bdb' is used.  This variable was added in MySQL 3.23.30.
  18260.  
  18261. `have_compress'
  18262.      Whether the `zlib' compression library is available to the server.
  18263.      If not, the `COMPRESS()' and `UNCOMPRESS()' functions cannot be
  18264.      used.  This variable was added in MySQL 4.1.1.
  18265.  
  18266. `have_crypt'
  18267.      Whether the `crypt()' system call is available to the server.  If
  18268.      not, the `CRYPT()' function cannot be used.  This variable was
  18269.      added in MySQL 4.0.10.
  18270.  
  18271. `have_geometry'
  18272.      Whether the server supports spatial data types.  This variable was
  18273.      added in MySQL 4.1.3.
  18274.  
  18275. `have_innodb'
  18276.      `YES' if `mysqld' supports `InnoDB' tables. `DISABLED' if
  18277.      `--skip-innodb' is used.  This variable was added in MySQL 3.23.37.
  18278.  
  18279. `have_isam'
  18280.      `YES' if `mysqld' supports `ISAM' tables. `DISABLED' if
  18281.      `--skip-isam' is used.  This variable was added in MySQL 3.23.30.
  18282.  
  18283. `have_ndbcluster'
  18284.      `YES' if `mysqld' supports `NDB Cluster' tables.  `DISABLED' if
  18285.      `--skip-ndbcluster' is used.  This variable was added in MySQL
  18286.      4.1.2.
  18287.  
  18288. `have_openssl'
  18289.      `YES' if `mysqld' supports SSL (encryption) of the client/server
  18290.      protocol.  This variable was added in MySQL 3.23.43.
  18291.  
  18292. `have_query_cache'
  18293.      `YES' if `mysqld' supports the query cache.  This variable was
  18294.      added in MySQL 4.0.2.
  18295.  
  18296. `have_raid'
  18297.      `YES' if `mysqld' supports the `RAID' option.  This variable was
  18298.      added in MySQL 3.23.30.
  18299.  
  18300. `have_rtree_keys'
  18301.      Whether `RTREE' indexes are available. (These are used for spatial
  18302.      indexed in `MyISAM' tables.)  This variable was added in MySQL
  18303.      4.1.3.
  18304.  
  18305. `have_symlink'
  18306.      Whether symbolic link support is enabled. This is required on Unix
  18307.      for support of the `DATA DIRECTORY' and `INDEX DIRECTORY' table
  18308.      options.  This variable was added in MySQL 4.0.0.
  18309.  
  18310. `init_connect'
  18311.      A string to be executed by the server for each client that
  18312.      connects.  The string consists of one or more SQL statements. To
  18313.      specify multiple statements, separate them by semicolon characters.
  18314.      For example, each client begins by default with autocommit mode
  18315.      enabled.  There is no global server variable to specify that
  18316.      autocommit should be disabled by default, but `init_connect' can
  18317.      be used to achieve the same effect:
  18318.  
  18319.           SET GLOBAL init_connect='SET AUTOCOMMIT=0';
  18320.  
  18321.      This variable can also be set on the command line or in an option
  18322.      file.  To set the variable as just shown using an option file,
  18323.      include these lines:
  18324.  
  18325.           [mysqld]
  18326.           init_connect='SET AUTOCOMMIT=0'
  18327.  
  18328.      Note that the content of `init_connect' is not executed for users
  18329.      having the `SUPER' privilege; this is in case that content has
  18330.      been wrongly set (contains a wrong query, for example with a
  18331.      syntax error), thus making all connections fail. Not executing it
  18332.      for `SUPER' users enables those to open a connection and fix
  18333.      `init_connect'.  This variable was added in MySQL 4.1.2.
  18334.  
  18335. `init_file'
  18336.      The name of the file specified with the `--init-file' option when
  18337.      you start the server.  This is a file containing SQL statements
  18338.      that you want the server to execute when it starts.  Each
  18339.      statement must be on a single line and should not include comments.
  18340.      This variable was added in MySQL 3.23.2.
  18341.  
  18342. `init_slave'
  18343.      This variable is similar to `init_connect', but is a string to be
  18344.      executed by a slave server each time the SQL thread starts.  The
  18345.      format of the string is the same as for the `init_connect'
  18346.      variable.  This variable was added in MySQL 4.1.2.
  18347.  
  18348. `innodb_XXX'
  18349.      The `InnoDB' system variables are listed at *Note `InnoDB' start:
  18350.      InnoDB start.
  18351.  
  18352. `interactive_timeout'
  18353.      The number of seconds the server waits for activity on an
  18354.      interactive connection before closing it.  An interactive client
  18355.      is defined as a client that uses the `CLIENT_INTERACTIVE' option to
  18356.      `mysql_real_connect()'.  See also `wait_timeout'.
  18357.  
  18358. `join_buffer_size'
  18359.      The size of the buffer that is used for full joins (joins that do
  18360.      not use indexes).  Normally the best way to get fast joins is to
  18361.      add indexes.  Increase the value of `join_buffer_size' to get a
  18362.      faster full join when adding indexes is not possible.  One join
  18363.      buffer is allocated for each full join between two tables. For a
  18364.      complex join between several tables for which indexes are not
  18365.      used, multiple join buffers might be necessary.
  18366.  
  18367. `key_buffer_size'
  18368.      Index blocks for `MyISAM' and `ISAM' tables are buffered and are
  18369.      shared by all threads.  `key_buffer_size' is the size of the buffer
  18370.      used for index blocks.  The key buffer is also known as the key
  18371.      cache.
  18372.  
  18373.      The maximum allowable setting for `key_buffer_size' is 4GB. The
  18374.      effective maximum size might be less, depending on your available
  18375.      physical RAM and per-process RAM limits imposed by your operating
  18376.      system or hardware platform.
  18377.  
  18378.      Increase the value to get better index handling (for all reads and
  18379.      multiple writes) to as much as you can afford. Using a value that
  18380.      is 25% of total memory on a machine that mainly runs MySQL is
  18381.      quite common.  However, if you make the value too large (for
  18382.      example, more than 50% of your total memory) your system might
  18383.      start to page and become extremely slow.  MySQL relies on the
  18384.      operating system to perform filesystem caching for data reads, so
  18385.      you must leave some room for the filesystem cache.
  18386.  
  18387.      For even more speed when writing many rows at the same time, use
  18388.      `LOCK TABLES'.  *Note `LOCK TABLES': LOCK TABLES.
  18389.  
  18390.      You can check the performance of the key buffer by issuing a `SHOW
  18391.      STATUS' statement and examining the `Key_read_requests',
  18392.      `Key_reads', `Key_write_requests', and `Key_writes' status
  18393.      variables.  *Note `SHOW': SHOW.
  18394.  
  18395.      The `Key_reads/Key_read_requests' ratio should normally be less
  18396.      than 0.01.  The `Key_writes/Key_write_requests' ratio is usually
  18397.      near 1 if you are using mostly updates and deletes, but might be
  18398.      much smaller if you tend to do updates that affect many rows at
  18399.      the same time or if you are using the `DELAY_KEY_WRITE' table
  18400.      option.
  18401.  
  18402.      The fraction of the key buffer in use can be determined using
  18403.      `key_buffer_size' in conjunction with the `Key_blocks_used' status
  18404.      variable and the buffer block size.  From MySQL 4.1.1 on, the
  18405.      buffer block size is available from the `key_cache_block_size'
  18406.      server variable. The fraction of the buffer in use is:
  18407.  
  18408.           (Key_blocks_used * key_cache_block_size) / key_buffer_size
  18409.  
  18410.      Before MySQL 4.1.1, key cache blocks are 1024 bytes, so the
  18411.      fraction of the key buffer in use is:
  18412.  
  18413.           (Key_blocks_used * 1024) / key_buffer_size
  18414.  
  18415.      *Note `MyISAM' key cache: MyISAM key cache.
  18416.  
  18417. `key_cache_age_threshold'
  18418.      This value controls the demotion of buffers from the hot sub-chain
  18419.      of a key cache to the warm sub-chain.  Lower values cause demotion
  18420.      to happen more quickly.  The minimum value is 100.  The default
  18421.      value is 300.  This variable was added in MySQL 4.1.1.  *Note
  18422.      `MyISAM' key cache: MyISAM key cache.
  18423.  
  18424. `key_cache_block_size'
  18425.      The size in bytes of blocks in the key cache.  The default value
  18426.      is 1024.  This variable was added in MySQL 4.1.1.  *Note `MyISAM'
  18427.      key cache: MyISAM key cache.
  18428.  
  18429. `key_cache_division_limit'
  18430.      The division point between the hot and warm sub-chains of the key
  18431.      cache buffer chain. The value is the percentage of the buffer
  18432.      chain to use for the warm sub-chain.  Allowable values range from
  18433.      1 to 100.  The default value is 100.  This variable was added in
  18434.      MySQL 4.1.1.  *Note `MyISAM' key cache: MyISAM key cache.
  18435.  
  18436. `language'
  18437.      The language used for error messages.
  18438.  
  18439. `large_file_support'
  18440.      Whether `mysqld' was compiled with options for large file support.
  18441.      This variable was added in MySQL 3.23.28.
  18442.  
  18443. `license'
  18444.      The type of license the server has.  This variable was added in
  18445.      MySQL 4.0.19.
  18446.  
  18447. `local_infile'
  18448.      Whether `LOCAL' is supported for `LOAD DATA INFILE' statements.
  18449.      This variable was added in MySQL 4.0.3.
  18450.  
  18451. `locked_in_memory'
  18452.      Whether `mysqld' was locked in memory with `--memlock'.  This
  18453.      variable was added in MySQL 3.23.25.
  18454.  
  18455. `log'
  18456.      Whether logging of all queries to the general query log is enabled.
  18457.      *Note Query log::.
  18458.  
  18459. `log_bin'
  18460.      Whether the binary log is enabled.  This variable was added in
  18461.      MySQL 3.23.14.  *Note Binary log::.
  18462.  
  18463. `log_error'
  18464.      The location of the error log.  This variable was added in MySQL
  18465.      4.0.10.
  18466.  
  18467. `log_slave_updates'
  18468.      Whether updates received by a slave server from a master server
  18469.      should be logged to the slave's own binary log. Binary logging
  18470.      must be enabled on the slave for this to have any effect.  This
  18471.      variable was added in MySQL 3.23.17.  *Note Replication Options::.
  18472.  
  18473. `log_slow_queries'
  18474.      Whether slow queries should be logged.  "Slow" is determined by
  18475.      the value of the `long_query_time' variable.  This variable was
  18476.      added in MySQL 4.0.2.  *Note Slow query log::.
  18477.  
  18478. `log_update'
  18479.      Whether the update log is enabled.  This variable was added in
  18480.      MySQL 3.22.18.  Note that the binary log is preferable to the
  18481.      update log, which is unavailable as of MySQL 5.0.  *Note Update
  18482.      log::.
  18483.  
  18484. `log_warnings'
  18485.      Whether to produce additional warning messages.  This variable was
  18486.      added in MySQL 4.0.3.  It is enabled by default as of MySQL 4.0.19
  18487.      and 4.1.2.  As of MySQL 4.0.21 and 4.1.3, aborted connections are
  18488.      not logged to the error log unless the value is greater than 1.
  18489.  
  18490. `long_query_time'
  18491.      If a query takes longer than this many seconds, the `Slow_queries'
  18492.      status variable is incremented. If you are using the
  18493.      `--log-slow-queries' option, the query is logged to the slow query
  18494.      log file. This value is measured in real time, not CPU time, so a
  18495.      query that is under the threshold on a lightly loaded system might
  18496.      be above the threshold on a heavily loaded one.  *Note Slow query
  18497.      log::.
  18498.  
  18499. `low_priority_updates'
  18500.      If set to `1', all `INSERT', `UPDATE', `DELETE', and `LOCK TABLE
  18501.      WRITE' statements wait until there is no pending `SELECT' or `LOCK
  18502.      TABLE READ' on the affected table.  This variable previously was
  18503.      named `sql_low_priority_updates'.  It was added in MySQL 3.22.5.
  18504.  
  18505. `lower_case_file_system'
  18506.      This variable indicates whether the filesystem where the data
  18507.      directory is located has case insensitive filenames.  `ON' means
  18508.      filenames are case insensitive, `OFF' means they are case
  18509.      sensitive.  This variable was added in MySQL 4.0.19.
  18510.  
  18511. `lower_case_table_names'
  18512.      If set to 1, table names are stored in lowercase on disk and table
  18513.      name comparisons are not case sensitive.  This variable was added
  18514.      in MySQL 3.23.6.  If set to 2 (new in 4.0.18), table names are
  18515.      stored as given but compared in lowercase.  From MySQL 4.0.2, this
  18516.      option also applies to database names.  From 4.1.1, it also
  18517.      applies to table aliases.  *Note Name case sensitivity::.
  18518.  
  18519.      You should _not_ set this variable to 0 if you are running MySQL
  18520.      on a system that does not have case-sensitive filenames (such as
  18521.      Windows or Mac OS X).  New in 4.0.18:  If this variable is not set
  18522.      at startup and the filesystem on which the data directory is
  18523.      located does not have case-sensitive filenames, MySQL
  18524.      automatically sets `lower_case_table_names' to 2.
  18525.  
  18526. `max_allowed_packet'
  18527.      The maximum size of one packet or any generated/intermediate
  18528.      string.
  18529.  
  18530.      The packet message buffer is initialized to `net_buffer_length'
  18531.      bytes, but can grow up to `max_allowed_packet' bytes when needed.
  18532.      This value by default is small, to catch big (possibly wrong)
  18533.      packets.
  18534.  
  18535.      You must increase this value if you are using big `BLOB' columns or
  18536.      long strings. It should be as big as the biggest `BLOB' you want to
  18537.      use.  The protocol limit for `max_allowed_packet' is 16MB before
  18538.      MySQL 4.0 and 1GB thereafter.
  18539.  
  18540. `max_binlog_cache_size'
  18541.      If a multiple-statement transaction requires more than this amount
  18542.      of memory, you will get the error `Multi-statement transaction
  18543.      required more than 'max_binlog_cache_size' bytes of storage'.
  18544.      This variable was added in MySQL 3.23.29.
  18545.  
  18546. `max_binlog_size'
  18547.      If a write to the binary log exceeds the given value, rotate the
  18548.      binary logs.  You cannot set this variable to more than 1GB or to
  18549.      less than 4096 bytes.  (The minimum before MYSQL 4.0.14 is 1024
  18550.      bytes.) The default value is 1GB.  This variable was added in
  18551.      MySQL 3.23.33.
  18552.  
  18553.      Note if you are using transactions: A transaction is written in
  18554.      one chunk to the binary log, hence it is never split between
  18555.      several binary logs.  Therefore, if you have big transactions, you
  18556.      might see binary logs bigger than `max_binlog_size'.
  18557.  
  18558.      If `max_relay_log_size' is 0, the value of `max_binlog_size'
  18559.      applies to relay logs as well. `max_relay_log_size' was added in
  18560.      MySQL 4.0.14.
  18561.  
  18562. `max_connect_errors'
  18563.      If there are more than this number of interrupted connections from
  18564.      a host, that host is blocked from further connections.  You can
  18565.      unblock blocked hosts with the `FLUSH HOSTS' statement.
  18566.  
  18567. `max_connections'
  18568.      The number of simultaneous client connections allowed. Increasing
  18569.      this value increases the number of file descriptors that `mysqld'
  18570.      requires.  See *Note Table cache:: for comments on file descriptor
  18571.      limits.  Also see *Note Too many connections::.
  18572.  
  18573. `max_delayed_threads'
  18574.      Don't start more than this number of threads to handle `INSERT
  18575.      DELAYED' statements.  If you try to insert data into a new table
  18576.      after all `INSERT DELAYED' threads are in use, the row will be
  18577.      inserted as if the `DELAYED' attribute wasn't specified. If you
  18578.      set this to 0, MySQL never creates a thread to handle `DELAYED'
  18579.      rows; in effect, this disables `DELAYED' entirely.  This variable
  18580.      was added in MySQL 3.23.0.
  18581.  
  18582. `max_error_count'
  18583.      The maximum number of error, warning, and note messages to be
  18584.      stored for display by `SHOW ERRORS' or `SHOW WARNINGS'.  This
  18585.      variable was added in MySQL 4.1.0.
  18586.  
  18587. `max_heap_table_size'
  18588.      This variable sets the maximum size to which `MEMORY' (`HEAP')
  18589.      tables are allowed to grow.  The value of the variable is used to
  18590.      calculate `MEMORY' table `MAX_ROWS' values.  Setting this variable
  18591.      has no effect on any existing `MEMORY' table, unless the table is
  18592.      re-created with a statement such as `CREATE TABLE' or `TRUNCATE
  18593.      TABLE', or altered with `ALTER TABLE'.  This variable was added in
  18594.      MySQL 3.23.0.
  18595.  
  18596. `max_insert_delayed_threads'
  18597.      This variable is a synonym for `max_delayed_threads'.  It was
  18598.      added in MySQL 4.0.19.
  18599.  
  18600. `max_join_size'
  18601.      Don't allow `SELECT' statements that probably will need to examine
  18602.      more than `max_join_size' row combinations or are likely to do more
  18603.      than `max_join_size' disk seeks.  By setting this value, you can
  18604.      catch `SELECT' statements where keys are not used properly and
  18605.      that would probably take a long time.  Set it if your users tend
  18606.      to perform joins that lack a `WHERE' clause, that take a long
  18607.      time, or that return millions of rows.
  18608.  
  18609.      Setting this variable to a value other than `DEFAULT' resets the
  18610.      `SQL_BIG_SELECTS' value to `0'.  If you set the `SQL_BIG_SELECTS'
  18611.      value again, the `max_join_size' variable is ignored.
  18612.  
  18613.      If a query result already is in the query cache, no result size
  18614.      check is performed, because the result has already been computed
  18615.      and it does not burden the server to send it to the client.
  18616.  
  18617.      This variable previously was named `sql_max_join_size'.
  18618.  
  18619. `max_length_for_sort_data'
  18620.      The cutoff on the size of index values that determines which
  18621.      `filesort' algorithm to use.  *Note `ORDER BY' optimization: ORDER
  18622.      BY optimization.  This variable was added in MySQL 4.1.1
  18623.  
  18624. `max_relay_log_size'
  18625.      If a write by a replication slave to its relay log exceeds the
  18626.      given value, rotate the relay log.  This variable enables you to
  18627.      put different size constraints on relay logs and binary logs.
  18628.      However, setting the variable to 0 makes MySQL use
  18629.      `max_binlog_size' for both binary logs and relay logs.  You must
  18630.      set `max_relay_log_size' to between 4096 bytes and 1GB
  18631.      (inclusive), or to 0. The default value is 0.  This variable was
  18632.      added in MySQL 4.0.14.  *Note Replication Implementation Details::.
  18633.  
  18634. `max_seeks_for_key'
  18635.      Limit the assumed maximum number of seeks when looking up rows
  18636.      based on a key.  The MySQL optimizer will assume that no more than
  18637.      this number of key seeks will be required when searching for
  18638.      matching rows in a table by scanning a key, regardless of the
  18639.      actual cardinality of the key (*note SHOW INDEX::). By setting
  18640.      this to a low value (100?), you can force MySQL to prefer keys
  18641.      instead of table scans.
  18642.  
  18643.      This variable was added in MySQL 4.0.14.
  18644.  
  18645. `max_sort_length'
  18646.      The number of bytes to use when sorting `BLOB' or `TEXT' values.
  18647.      Only the first `max_sort_length' bytes of each value are used; the
  18648.      rest are ignored.
  18649.  
  18650. `max_tmp_tables'
  18651.      The maximum number of temporary tables a client can keep open at
  18652.      the same time.  (This option doesn't yet do anything.)
  18653.  
  18654. `max_user_connections'
  18655.      The maximum number of simultaneous connections allowed to any
  18656.      given MySQL account.  A value of 0 means "no limit."  This
  18657.      variable was added in MySQL 3.23.34.
  18658.  
  18659. `max_write_lock_count'
  18660.      After this many write locks, allow some read locks to run in
  18661.      between.  This variable was added in MySQL 3.23.7.
  18662.  
  18663. `myisam_data_pointer_size'
  18664.      The default pointer size in bytes, to be used by `CREATE TABLE' for
  18665.      `MyISAM' tables when no `MAX_ROWS' option is specified.  This
  18666.      variable cannot be less than 2 or larger than 8.  The default
  18667.      value is 4.  This variable was added in MySQL 4.1.2.  *Note
  18668.      `myisam_data_pointer_size': Full table.
  18669.  
  18670. `myisam_max_extra_sort_file_size'
  18671.      If the temporary file used for fast `MyISAM' index creation would
  18672.      be larger than using the key cache by the amount specified here,
  18673.      prefer the key cache method.  This is mainly used to force long
  18674.      character keys in large tables to use the slower key cache method
  18675.      to create the index.  This variable was added in MySQL 3.23.37.
  18676.      *Note*: The value is given in megabytes before 4.0.3 and in bytes
  18677.      thereafter.
  18678.  
  18679. `myisam_max_sort_file_size'
  18680.      The maximum size of the temporary file MySQL is allowed to use
  18681.      while re-creating a `MyISAM' index (during `REPAIR TABLE', `ALTER
  18682.      TABLE', or `LOAD DATA INFILE').  If the file size would be bigger
  18683.      than this value, the index will be created using the key cache
  18684.      instead, which is slower.  This variable was added in MySQL
  18685.      3.23.37.  *Note*: The value is given in megabytes before 4.0.3 and
  18686.      in bytes thereafter.
  18687.  
  18688. `myisam_recover_options'
  18689.      The value of the `--myisam-recover' option.  This variable was
  18690.      added in MySQL 3.23.36.
  18691.  
  18692. `myisam_repair_threads'
  18693.      If this value is greater than 1, `MyISAM' table indexes are
  18694.      created in parallel (each index in its own thread) during the
  18695.      `Repair by sorting' process.  The default value is 1.  *Note*:
  18696.      Multi-threaded repair is still _alpha_ quality code.  This
  18697.      variable was added in MySQL 4.0.13.
  18698.  
  18699. `myisam_sort_buffer_size'
  18700.      The buffer that is allocated when sorting `MyISAM' indexes during a
  18701.      `REPAIR TABLE' or when creating indexes with `CREATE INDEX' or
  18702.      `ALTER TABLE'.  This variable was added in MySQL 3.23.16.
  18703.  
  18704. `named_pipe'
  18705.      On Windows, indicates whether the server supports connections over
  18706.      named pipes.  This variable was added in MySQL 3.23.50.
  18707.  
  18708. `net_buffer_length'
  18709.      The communication buffer is reset to this size between queries.
  18710.      This should not normally be changed, but if you have very little
  18711.      memory, you can set it to the expected length of SQL statements
  18712.      sent by clients.  If statements exceed this length, the buffer is
  18713.      automatically enlarged, up to `max_allowed_packet' bytes.
  18714.  
  18715. `net_read_timeout'
  18716.      The number of seconds to wait for more data from a connection
  18717.      before aborting the read.  When the server is reading from the
  18718.      client, `net_read_timeout' is the timeout value controlling when
  18719.      to abort.  When the server is writing to the client,
  18720.      `net_write_timeout' is the timeout value controlling when to abort.
  18721.      See also `slave_net_timeout'.  This variable was added in MySQL
  18722.      3.23.20.
  18723.  
  18724. `net_retry_count'
  18725.      If a read on a communication port is interrupted, retry this many
  18726.      times before giving up.  This value should be set quite high on
  18727.      FreeBSD because internal interrupts are sent to all threads.  This
  18728.      variable was added in MySQL 3.23.7.
  18729.  
  18730. `net_write_timeout'
  18731.      The number of seconds to wait for a block to be written to a
  18732.      connection before aborting the write.  See also `net_read_timeout'.
  18733.      This variable was added in MySQL 3.23.20.
  18734.  
  18735. `new'
  18736.      This variable is used in MySQL 4.0 to turn on some 4.1 behaviors.
  18737.      This variable was added in MySQL 4.0.12.
  18738.  
  18739. `old_passwords'
  18740.      Whether the server should use pre-4.1-style passwords for MySQL
  18741.      user accounts.  This variable was added in MySQL 4.1.1.
  18742.  
  18743. `open_files_limit'
  18744.      The number of files that the operating system allows `mysqld' to
  18745.      open.  This is the real value allowed by the system and might be
  18746.      different from the value you gave `mysqld' as a startup option.
  18747.      The value is 0 on systems where MySQL can't change the number of
  18748.      open files.  This variable was added in MySQL 3.23.20.
  18749.  
  18750. `optimizer_prune_level'
  18751.      Controls the heuristics applied during query optimization to prune
  18752.      less-promising partial plans from the optimizer search space. A
  18753.      value of 0 disables heuristics so that the optimizer performs an
  18754.      exhaustive search. A value of 1 causes the optimizer to prune
  18755.      plans based on the number of rows retrieved by intermediate plans.
  18756.      This variable was added in MySQL 5.0.1.
  18757.  
  18758. `optimizer_search_depth'
  18759.      The maximum depth of search performed by the query optimizer.
  18760.      Values larger than the number of relations in a query result in
  18761.      better query plans, but take longer to generate an execution plan
  18762.      for a query. Values smaller than the number of relations in a
  18763.      query return an execution plan quicker, but the resulting plan may
  18764.      be far from being optimal. If set to 0, the system automatically
  18765.      picks a reasonable value. If set to the maximum number of tables
  18766.      used in a query plus 2, the optimizer switches to the original
  18767.      algorithm used before MySQL 5.0.1 that performs an exhaustive
  18768.      search.  This variable was added in MySQL 5.0.1.
  18769.  
  18770. `pid_file'
  18771.      The pathname of the process ID (PID) file. This variable can be set
  18772.      with the `--pid-file' option.  This variable was added in MySQL
  18773.      3.23.23.
  18774.  
  18775. `port'
  18776.      The port on which the server listens for TCP/IP connections.  This
  18777.      variable can be set with the `--port' option.
  18778.  
  18779. `preload_buffer_size'
  18780.      The size of the buffer that is allocated when preloading indexes.
  18781.      This variable was added in MySQL 4.1.1.
  18782.  
  18783. `protocol_version'
  18784.      The version of the client/server protocol used by the MySQL server.
  18785.      This variable was added in MySQL 3.23.18.
  18786.  
  18787. `query_alloc_block_size'
  18788.      The allocation size of memory blocks that are allocated for
  18789.      objects created during query parsing and execution. If you have
  18790.      problems with memory fragmentation, it might help to increase this
  18791.      a bit.  This variable was added in MySQL 4.0.16.
  18792.  
  18793. `query_cache_limit'
  18794.      Don't cache results that are bigger than this. The default value
  18795.      is 1MB.  This variable was added in MySQL 4.0.1.
  18796.  
  18797. `query_cache_min_res_unit'
  18798.      The minimum size for blocks allocated by the query cache.  The
  18799.      default value is 4KB. Tuning information for this variable is
  18800.      given in *Note Query Cache Configuration::.  This variable is
  18801.      present from MySQL 4.1.
  18802.  
  18803. `query_cache_size'
  18804.      The amount of memory allocated for caching query results.  The
  18805.      default value is 0, which disables the query cache.  Note that
  18806.      this amount of memory will be allocated even if `query_cache_type'
  18807.      is set to 0.  This variable was added in MySQL 4.0.1.
  18808.  
  18809. `query_cache_type'
  18810.      Set query cache type. Setting the `GLOBAL' value sets the type for
  18811.      all clients that connect thereafter. Individual clients can set the
  18812.      `SESSION' value to affect their own use of the query cache.
  18813.  
  18814.      *Option*   *Description*
  18815.      `0' or     Don't cache or retrieve results.  Note that
  18816.      `OFF'      this will not deallocate the query cache
  18817.                 buffer. To do that, you should set
  18818.                 `query_cache_size' to 0.
  18819.      `1' or     Cache all query results except for those that
  18820.      `ON'       begin with `SELECT SQL_NO_CACHE'.
  18821.      `2' or     Cache results only for queries that begin with
  18822.      `DEMAND'   `SELECT SQL_CACHE'.
  18823.  
  18824.      This variable was added in MySQL 4.0.3.
  18825.  
  18826. `query_cache_wlock_invalidate'
  18827.      Normally, when one client acquires a `WRITE' lock on a `MyISAM'
  18828.      table, other clients are not blocked from issuing queries for the
  18829.      table if the query results are present in the query cache. Setting
  18830.      this variable to 1 causes acquisition of a `WRITE' lock for a
  18831.      table to invalidate any queries in the query cache that refer to
  18832.      the table. This forces other clients that attempt to access the
  18833.      table to wait while the lock is in effect.  This variable was
  18834.      added in MySQL 4.0.19.
  18835.  
  18836. `query_prealloc_size'
  18837.      The size of the persistent buffer used for query parsing and
  18838.      execution.  This buffer is not freed between queries.  If you are
  18839.      running complex queries, a larger `query_prealloc_size' value
  18840.      might be helpful in improving performance, because it can reduce
  18841.      the need for the server to perform memory allocation during query
  18842.      execution operations.  This variable was added in MySQL 4.0.16.
  18843.  
  18844. `range_alloc_block_size'
  18845.      The size of blocks that are allocated when doing range
  18846.      optimization.  This variable was added in MySQL 4.0.16.
  18847.  
  18848. `read_buffer_size'
  18849.      Each thread that does a sequential scan allocates a buffer of this
  18850.      size for each table it scans. If you do many sequential scans, you
  18851.      might want to increase this value.  This variable was added in
  18852.      MySQL 4.0.3.  Previously, it was named `record_buffer'.
  18853.  
  18854. `read_only'
  18855.      When the variable is set to `ON' for a replication slave server, it
  18856.      causes the slave to allow no updates except from slave threads or
  18857.      from users with the `SUPER' privilege.  This can be useful to
  18858.      ensure that a slave server accepts no updates from clients.  This
  18859.      variable was added in MySQL 4.0.14.
  18860.  
  18861. `relay_log_purge'
  18862.      Disables or enables automatic purging of relay logs as soon as
  18863.      they are not needed any more.  The default value is 1 (enabled).
  18864.      This variable was added in MySQL 4.1.1.
  18865.  
  18866. `read_rnd_buffer_size'
  18867.      When reading rows in sorted order after a sort, the rows are read
  18868.      through this buffer to avoid disk seeks.  Setting the variable to
  18869.      a large value can improve `ORDER BY' performance by a lot.
  18870.      However, this is a buffer allocated for each client, so you should
  18871.      not set the global variable to a large value. Instead, change the
  18872.      session variable only from within those clients that need to run
  18873.      large queries.  This variable was added in MySQL 4.0.3.
  18874.      Previously, it was named `record_rnd_buffer'.
  18875.  
  18876. `safe_show_database'
  18877.      Don't show databases for which the user has no database or table
  18878.      privileges. This can improve security if you're concerned about
  18879.      people being able to see what databases other users have. See also
  18880.      `skip_show_database'.
  18881.  
  18882.      This variable was removed in MySQL 4.0.5. Instead, use the `SHOW
  18883.      DATABASES' privilege to control access by MySQL accounts to
  18884.      database names.
  18885.  
  18886. `secure_auth'
  18887.      If the MySQL server has been started with the `--secure-auth'
  18888.      option, it blocks connections from all accounts that have
  18889.      passwords stored in the old (pre-4.1) format. In that case, the
  18890.      value of this variable is `ON', otherwise it is `OFF'.
  18891.  
  18892.      You should enable this option if you want to prevent all usage of
  18893.      passwords in old format (and hence insecure communication over the
  18894.      network).  This variable was added in MySQL 4.1.1.
  18895.  
  18896.      Server startup will fail with an error if this option is enabled
  18897.      and the privilege tables are in pre-4.1 format.
  18898.  
  18899.      When used as a client-side option, the client refuses to connect
  18900.      to a server if the server requires a password in old format for
  18901.      the client account.
  18902.  
  18903. `server_id'
  18904.      The value of the `--server-id' option. It is used for master and
  18905.      slave replication servers.  This variable was added in MySQL
  18906.      3.23.26.
  18907.  
  18908. `shared_memory'
  18909.      Whether or not the server allows shared-memory connections.
  18910.      Currently, only Windows servers support this.  This variable was
  18911.      added in MySQL 4.1.1.
  18912.  
  18913. `shared_memory_base_name'
  18914.      Whether or not the server allows shared-memory connections.
  18915.      Currently, only Windows servers support this.  This variable was
  18916.      added in MySQL 4.1.0.
  18917.  
  18918. `skip_external_locking'
  18919.      This is `OFF' if `mysqld' uses external locking.  This variable
  18920.      was added in MySQL 4.0.3.  Previously, it was named `skip_locking'.
  18921.  
  18922. `skip_networking'
  18923.      This is `ON' if the server allows only local (non-TCP/IP)
  18924.      connections.  On Unix, local connections use a Unix socket file.
  18925.      On Windows, local connections use a named pipe.  On NetWare, only
  18926.      TCP/IP connections are supported, so do not set this variable to
  18927.      `ON'.  This variable was added in MySQL 3.22.23.
  18928.  
  18929. `skip_show_database'
  18930.      This prevents people from using the `SHOW DATABASES' statement if
  18931.      they don't have the `SHOW DATABASES' privilege. This can improve
  18932.      security if you're concerned about people being able to see what
  18933.      databases other users have. See also `safe_show_database'.  This
  18934.      variable was added in MySQL 3.23.4.  As of MySQL 4.0.2, its effect
  18935.      also depends on the `SHOW DATABASES' privilege: If the variable
  18936.      value is `ON', the `SHOW DATABASES' statement is allowed only to
  18937.      users who have the `SHOW DATABASES' privilege, and the statement
  18938.      displays all database names.  If the value is `OFF', `SHOW
  18939.      DATABASES' is allowed to all users, but displays each database
  18940.      name only if the user has the `SHOW DATABASES' privilege or some
  18941.      privilege for the database.
  18942.  
  18943. `slave_compressed_protocol'
  18944.      Whether to use compression of the slave/master protocol if both the
  18945.      slave and the master support it.  This variable was added in MySQL
  18946.      4.0.3.
  18947.  
  18948. `slave_net_timeout'
  18949.      The number of seconds to wait for more data from a master/slave
  18950.      connection before aborting the read.  This variable was added in
  18951.      MySQL 3.23.40.
  18952.  
  18953. `slow_launch_time'
  18954.      If creating a thread takes longer than this many seconds, the
  18955.      server increments the `Slow_launch_threads' status variable.  This
  18956.      variable was added in MySQL 3.23.15.
  18957.  
  18958. `socket'
  18959.      On Unix, this is the Unix socket file used for local client
  18960.      connections.  On Windows, this is the name of the named pipe used
  18961.      for local client connections.
  18962.  
  18963. `sort_buffer_size'
  18964.      Each thread that needs to do a sort allocates a buffer of this
  18965.      size. Increase this value for faster `ORDER BY' or `GROUP BY'
  18966.      operations.  *Note Temporary files::.
  18967.  
  18968. `sql_mode'
  18969.      The current server SQL mode.  This variable was added in MySQL
  18970.      3.23.41.  It can be set dynamically as of MySQL 4.1.1.  *Note
  18971.      Server SQL mode::.
  18972.  
  18973. `sql_slave_skip_counter'
  18974.      The number of events from the master that a slave server should
  18975.      skip.  It was added in MySQL 3.23.33.
  18976.  
  18977. `storage_engine'
  18978.      This variable is a synonym for `table_type'.  It was added in
  18979.      MySQL 4.1.2.
  18980.  
  18981. `sync_binlog'
  18982.      If positive, the MySQL server will synchronize its binary log to
  18983.      disk (`fdatasync()') after every `sync_binlog''th write to this
  18984.      binary log. Note that there is one write to the binary log per
  18985.      statement if in autocommit mode, and otherwise one write per
  18986.      transaction. The default value is 0 which does no sync'ing to
  18987.      disk. A value of 1 is the safest choice, because in case of crash
  18988.      you will lose at most one statement/transaction from the binary
  18989.      log; but it is also the slowest choice (unless the disk has a
  18990.      battery-backed cache, which makes sync'ing very fast). This
  18991.      variable was added in MySQL 4.1.3.
  18992.  
  18993. `sync_frm'
  18994.      This was added as a command-line option in MySQL 4.0.18, and is
  18995.      also a settable global variable since MySQL 4.1.3. If set to 1,
  18996.      when a non-temporary table is created it will synchronize its
  18997.      `.frm' file to disk (`fdatasync()'); this is slower but safer in
  18998.      case of crash. Default is 1.
  18999.  
  19000. `system_time_zone'
  19001.      The server system time zone. When the server starts, it attempts
  19002.      to determine the time zone of the host machine. For example, if
  19003.      the `TZ' environment variable is set, its value is used to set
  19004.      `system_time_zone'.  This variable was added in MySQL 4.1.3.
  19005.  
  19006. `table_cache'
  19007.      The number of open tables for all threads. Increasing this value
  19008.      increases the number of file descriptors that `mysqld' requires.
  19009.      You can check whether you need to increase the table cache by
  19010.      checking the `Opened_tables' status variable.  *Note Server status
  19011.      variables::.  If the value of `Opened_tables' is large and you
  19012.      don't do `FLUSH TABLES' a lot (which just forces all tables to be
  19013.      closed and reopened), then you should increase the value of the
  19014.      `table_cache' variable.
  19015.  
  19016.      For more information about the table cache, see *Note Table
  19017.      cache::.
  19018.  
  19019. `table_type'
  19020.      The default table type (storage engine).  To set the table type at
  19021.      server startup, use the `--default-table-type' option.  This
  19022.      variable was added in MySQL 3.23.0.  *Note Server options::.
  19023.  
  19024. `thread_cache_size'
  19025.      How many threads the server should cache for reuse.  When a client
  19026.      disconnects, the client's threads are put in the cache if there
  19027.      aren't already `thread_cache_size' threads there.  Requests for
  19028.      threads are satisfied by reusing threads taken from the cache if
  19029.      possible, and only when the cache is empty is a new thread
  19030.      created.  This variable can be increased to improve performance if
  19031.      you have a lot of new connections. (Normally this doesn't give a
  19032.      notable performance improvement if you have a good thread
  19033.      implementation.)  By examining the difference between the
  19034.      `Connections' and `Threads_created' status variables (*note Server
  19035.      status variables:: for details) you can see how efficient the
  19036.      thread cache is.  This variable was added in MySQL 3.23.16.
  19037.  
  19038. `thread_concurrency'
  19039.      On Solaris, `mysqld' calls `thr_setconcurrency()' with this value.
  19040.      This function allows applications to give the threads system a
  19041.      hint about the desired number of threads that should be run at the
  19042.      same time.  This variable was added in MySQL 3.23.7.
  19043.  
  19044. `thread_stack'
  19045.      The stack size for each thread.  Many of the limits detected by the
  19046.      `crash-me' test are dependent on this value. The default is large
  19047.      enough for normal operation.  *Note MySQL Benchmarks::.
  19048.  
  19049. `time_zone'
  19050.      The current time zone. The initial value of this is `'SYSTEM''
  19051.      (use the value of `system_time_zone'), but can be specified
  19052.      explicitly at server startup time with the `--default-time-zone'
  19053.      option.  This variable was added in MySQL 4.1.3.
  19054.  
  19055. `timezone'
  19056.      The time zone for the server.  This is set from the `TZ'
  19057.      environment variable when `mysqld' is started.  The time zone also
  19058.      can be set by giving a `--timezone' argument to `mysqld_safe'.
  19059.      This variable was added in MySQL 3.23.15. As of MySQL 4.1.3, it is
  19060.      obsolete and has been replaced by the `system_time_zone' variable.
  19061.      *Note Timezone problems::.
  19062.  
  19063. `tmp_table_size'
  19064.      If an in-memory temporary table exceeds this size, MySQL
  19065.      automatically converts it to an on-disk `MyISAM' table.  Increase
  19066.      the value of `tmp_table_size' if you do many advanced `GROUP BY'
  19067.      queries and you have lots of memory.
  19068.  
  19069. `tmpdir'
  19070.      The directory used for temporary files and temporary tables.
  19071.      Starting from MySQL 4.1, this variable can be set to a list of
  19072.      several paths that are used in round-robin fashion. Paths should
  19073.      be separated by colon characters (`:') on Unix and semicolon
  19074.      characters (`;') on Windows, NetWare, and OS/2.
  19075.  
  19076.      This feature can be used to spread the load between several
  19077.      physical disks.  If the MySQL server is acting as a replication
  19078.      slave, you should not set `tmpdir' to point to a directory on a
  19079.      memory-based filesystem or to a directory that is cleared when the
  19080.      server host restarts.  A replication slave needs some of its
  19081.      temporary files to survive a machine restart so that it can
  19082.      replicate temporary tables or `LOAD DATA INFILE' operations. If
  19083.      files in the temporary file directory are lost when the server
  19084.      restarts, replication will fail.
  19085.  
  19086.      This variable was added in MySQL 3.22.4.
  19087.  
  19088. `transaction_alloc_block_size'
  19089.      The allocation size of memory blocks that are allocated for
  19090.      storing queries that are part of a transaction to be stored in the
  19091.      binary log when doing a commit.  This variable was added in MySQL
  19092.      4.0.16.
  19093.  
  19094. `transaction_prealloc_size'
  19095.      The size of the persistent buffer for `transaction_alloc_blocks'
  19096.      that is not freed between queries. By making this big enough to
  19097.      fit all queries in a common transaction, you can avoid a lot of
  19098.      `malloc()' calls.  This variable was added in MySQL 4.0.16.
  19099.  
  19100. `tx_isolation'
  19101.      The default transaction isolation level.  This variable was added
  19102.      in MySQL 4.0.3.
  19103.  
  19104. `updatable_views_with_limit'
  19105.      This variable controls whether updates can be made using a view
  19106.      that does not contain a primary key in the underlying table, if
  19107.      the update contains a `LIMIT' clause. (Such updates often are
  19108.      generated by GUI tools.)  An update is an `UPDATE' or `DELETE'
  19109.      statement.  Primary key here means a `PRIMARY KEY', or a `UNIQUE'
  19110.      index in which no column can contain `NULL'.
  19111.  
  19112.      The variable can have two values:
  19113.  
  19114.         * `1' or `YES': Issue a warning only (not an error message).
  19115.           This is the default value.
  19116.  
  19117.         * `0' or `NO': Prohibit the update.
  19118.  
  19119.      This variable was added in MySQL 5.0.2.
  19120.  
  19121. `version'
  19122.      The version number for the server.
  19123.  
  19124. `version_bdb'
  19125.      The `BDB' storage engine version.  This variable was added in
  19126.      MySQL 3.23.31 with the name `bdb_version' and renamed to
  19127.      `version_bdb' in MySQL 4.1.1.
  19128.  
  19129. `version_comment'
  19130.      The `configure' script has a `--with-comment' option that allows a
  19131.      comment to be specified when building MySQL.  This variable
  19132.      contains the value of that comment.  This variable was added in
  19133.      MySQL 4.0.17.
  19134.  
  19135. `version_compile_machine'
  19136.      The type of machine MySQL was built on.  This variable was added
  19137.      in MySQL 4.1.1.
  19138.  
  19139. `version_compile_os'
  19140.      The type of operating system MySQL was built on.  This variable
  19141.      was added in MySQL 4.0.19.
  19142.  
  19143. `wait_timeout'
  19144.      The number of seconds the server waits for activity on a
  19145.      non-interactive connection before closing it.
  19146.  
  19147.      On thread startup, the session `wait_timeout' value is initialized
  19148.      from the global `wait_timeout' value or from the global
  19149.      `interactive_timeout' value, depending on the type of client (as
  19150.      defined by the `CLIENT_INTERACTIVE' connect option to
  19151.      `mysql_real_connect()'). See also `interactive_timeout'.
  19152.  
  19153. Dynamic System Variables
  19154. ........................
  19155.  
  19156. Beginning with MySQL 4.0.3, many server system variables are dynamic
  19157. and can be set at runtime using `SET GLOBAL' or `SET SESSION'. You can
  19158. also select their values using `SELECT'.  *Note System Variables::.
  19159.  
  19160. The following table shows the full list of all dynamic system variables.
  19161. The last column indicates for each variable whether `GLOBAL' or
  19162. `SESSION' (or both) apply.
  19163.  
  19164. *Variable Name*                  *Value Type*       *Type*
  19165. `autocommit'                     boolean            `SESSION'
  19166. `big_tables'                     boolean            `SESSION'
  19167. `binlog_cache_size'              numeric            `GLOBAL'
  19168. `bulk_insert_buffer_size'        numeric            `GLOBAL' | `SESSION'
  19169. `character_set_client'           string             `GLOBAL' | `SESSION'
  19170. `character_set_connection'       string             `GLOBAL' | `SESSION'
  19171. `character_set_results'          string             `GLOBAL' | `SESSION'
  19172. `character_set_server'           string             `GLOBAL' | `SESSION'
  19173. `collation_connection'           string             `GLOBAL' | `SESSION'
  19174. `collation_server'               string             `GLOBAL' | `SESSION'
  19175. `concurrent_insert'              boolean            `GLOBAL'
  19176. `connect_timeout'                numeric            `GLOBAL'
  19177. `convert_character_set'          string             `GLOBAL' | `SESSION'
  19178. `default_week_format'            numeric            `GLOBAL' | `SESSION'
  19179. `delay_key_write'                `OFF' | `ON' |     `GLOBAL'
  19180.                                  `ALL'              
  19181. `delayed_insert_limit'           numeric            `GLOBAL'
  19182. `delayed_insert_timeout'         numeric            `GLOBAL'
  19183. `delayed_queue_size'             numeric            `GLOBAL'
  19184. `error_count'                    numeric            `SESSION'
  19185. `expire_logs_days'               numeric            `GLOBAL'
  19186. `flush'                          boolean            `GLOBAL'
  19187. `flush_time'                     numeric            `GLOBAL'
  19188. `foreign_key_checks'             boolean            `SESSION'
  19189. `ft_boolean_syntax'              numeric            `GLOBAL'
  19190. `group_concat_max_len'           numeric            `GLOBAL' | `SESSION'
  19191. `identity'                       numeric            `SESSION'
  19192. `insert_id'                      boolean            `SESSION'
  19193. `interactive_timeout'            numeric            `GLOBAL' | `SESSION'
  19194. `join_buffer_size'               numeric            `GLOBAL' | `SESSION'
  19195. `key_buffer_size'                numeric            `GLOBAL'
  19196. `last_insert_id'                 numeric            `SESSION'
  19197. `local_infile'                   boolean            `GLOBAL'
  19198. `log_warnings'                   numeric            `GLOBAL'
  19199. `long_query_time'                numeric            `GLOBAL' | `SESSION'
  19200. `low_priority_updates'           boolean            `GLOBAL' | `SESSION'
  19201. `max_allowed_packet'             numeric            `GLOBAL' | `SESSION'
  19202. `max_binlog_cache_size'          numeric            `GLOBAL'
  19203. `max_binlog_size'                numeric            `GLOBAL'
  19204. `max_connect_errors'             numeric            `GLOBAL'
  19205. `max_connections'                numeric            `GLOBAL'
  19206. `max_delayed_threads'            numeric            `GLOBAL'
  19207. `max_error_count'                numeric            `GLOBAL' | `SESSION'
  19208. `max_heap_table_size'            numeric            `GLOBAL' | `SESSION'
  19209. `max_insert_delayed_threads'     numeric            `GLOBAL'
  19210. `max_join_size'                  numeric            `GLOBAL' | `SESSION'
  19211. `max_relay_log_size'             numeric            `GLOBAL'
  19212. `max_seeks_for_key'              numeric            `GLOBAL' | `SESSION'
  19213. `max_sort_length'                numeric            `GLOBAL' | `SESSION'
  19214. `max_tmp_tables'                 numeric            `GLOBAL' | `SESSION'
  19215. `max_user_connections'           numeric            `GLOBAL'
  19216. `max_write_lock_count'           numeric            `GLOBAL'
  19217. `myisam_data_pointer_size'       numeric            `GLOBAL'
  19218. `myisam_max_extra_sort_file_size'numeric            `GLOBAL' | `SESSION'
  19219. `myisam_max_sort_file_size'      numeric            `GLOBAL' | `SESSION'
  19220. `myisam_repair_threads'          numeric            `GLOBAL' | `SESSION'
  19221. `myisam_sort_buffer_size'        numeric            `GLOBAL' | `SESSION'
  19222. `net_buffer_length'              numeric            `GLOBAL' | `SESSION'
  19223. `net_read_timeout'               numeric            `GLOBAL' | `SESSION'
  19224. `net_retry_count'                numeric            `GLOBAL' | `SESSION'
  19225. `net_write_timeout'              numeric            `GLOBAL' | `SESSION'
  19226. `old_passwords'                  numeric            `GLOBAL' | `SESSION'
  19227. `optimizer_prune_level'          numeric            `GLOBAL' | `SESSION'
  19228. `optimizer_search_depth'         numeric            `GLOBAL' | `SESSION'
  19229. `preload_buffer_size'            numeric            `GLOBAL' | `SESSION'
  19230. `query_alloc_block_size'         numeric            `GLOBAL' | `SESSION'
  19231. `query_cache_limit'              numeric            `GLOBAL'
  19232. `query_cache_size'               numeric            `GLOBAL'
  19233. `query_cache_type'               enumeration        `GLOBAL' | `SESSION'
  19234. `query_cache_wlock_invalidate'   boolean            `GLOBAL' | `SESSION'
  19235. `query_prealloc_size'            numeric            `GLOBAL' | `SESSION'
  19236. `range_alloc_block_size'         numeric            `GLOBAL' | `SESSION'
  19237. `read_buffer_size'               numeric            `GLOBAL' | `SESSION'
  19238. `read_only'                      numeric            `GLOBAL'
  19239. `read_rnd_buffer_size'           numeric            `GLOBAL' | `SESSION'
  19240. `rpl_recovery_rank'              numeric            `GLOBAL'
  19241. `safe_show_database'             boolean            `GLOBAL'
  19242. `secure_auth'                    boolean            `GLOBAL'
  19243. `server_id'                      numeric            `GLOBAL'
  19244. `slave_compressed_protocol'      boolean            `GLOBAL'
  19245. `slave_net_timeout'              numeric            `GLOBAL'
  19246. `slow_launch_time'               numeric            `GLOBAL'
  19247. `sort_buffer_size'               numeric            `GLOBAL' | `SESSION'
  19248. `sql_auto_is_null'               boolean            `SESSION'
  19249. `sql_big_selects'                boolean            `SESSION'
  19250. `sql_big_tables'                 boolean            `SESSION'
  19251. `sql_buffer_result'              boolean            `SESSION'
  19252. `sql_log_bin'                    boolean            `SESSION'
  19253. `sql_log_off'                    boolean            `SESSION'
  19254. `sql_log_update'                 boolean            `SESSION'
  19255. `sql_low_priority_updates'       boolean            `GLOBAL' | `SESSION'
  19256. `sql_max_join_size'              numeric            `GLOBAL' | `SESSION'
  19257. `sql_mode'                       enumeration        `GLOBAL' | `SESSION'
  19258. `sql_quote_show_create'          boolean            `SESSION'
  19259. `sql_safe_updates'               boolean            `SESSION'
  19260. `sql_select_limit'               numeric            `SESSION'
  19261. `sql_slave_skip_counter'         numeric            `GLOBAL'
  19262. `updatable_views_with_limit'     enumeration        `GLOBAL' | `SESSION'
  19263. `sql_warnings'                   boolean            `SESSION'
  19264. `sync_binlog'                    numeric            `GLOBAL'
  19265. `sync_frm'                       boolean            `GLOBAL'
  19266. `storage_engine'                 enumeration        `GLOBAL' | `SESSION'
  19267. `table_cache'                    numeric            `GLOBAL'
  19268. `table_type'                     enumeration        `GLOBAL' | `SESSION'
  19269. `thread_cache_size'              numeric            `GLOBAL'
  19270. `time_zone'                      string             `GLOBAL' | `SESSION'
  19271. `timestamp'                      boolean            `SESSION'
  19272. `tmp_table_size'                 enumeration        `GLOBAL' | `SESSION'
  19273. `transaction_alloc_block_size'   numeric            `GLOBAL' | `SESSION'
  19274. `transaction_prealloc_size'      numeric            `GLOBAL' | `SESSION'
  19275. `tx_isolation'                   enumeration        `GLOBAL' | `SESSION'
  19276. `unique_checks'                  boolean            `SESSION'
  19277. `wait_timeout'                   numeric            `GLOBAL' | `SESSION'
  19278. `warning_count'                  numeric            `SESSION'
  19279.  
  19280. Variables that are marked as "string" take a string value.  Variables
  19281. that are marked as "numeric" take a numeric value. Variables that are
  19282. marked as "boolean" can be set to 0, 1, `ON' or `OFF'. Variables that
  19283. are marked as "enumeration" normally should be set to one of the
  19284. available values for the variable, but can also be set to the number
  19285. that corresponds to the desired enumeration value.  For
  19286. enumeration-valued system variables, the first enumeration value
  19287. corresponds to 0. This differs from `ENUM' columns, for which the first
  19288. enumeration value corresponds to 1.
  19289.  
  19290. Server Status Variables
  19291. -----------------------
  19292.  
  19293. The server maintains many status variables that provide information
  19294. about its operations. You can view these variables and their values by
  19295. using the `SHOW STATUS' statement:
  19296.  
  19297.      mysql> SHOW STATUS;
  19298.      +--------------------------+------------+
  19299.      | Variable_name            | Value      |
  19300.      +--------------------------+------------+
  19301.      | Aborted_clients          | 0          |
  19302.      | Aborted_connects         | 0          |
  19303.      | Bytes_received           | 155372598  |
  19304.      | Bytes_sent               | 1176560426 |
  19305.      | Connections              | 30023      |
  19306.      | Created_tmp_disk_tables  | 0          |
  19307.      | Created_tmp_files        | 60         |
  19308.      | Created_tmp_tables       | 8340       |
  19309.      | Delayed_errors           | 0          |
  19310.      | Delayed_insert_threads   | 0          |
  19311.      | Delayed_writes           | 0          |
  19312.      | Flush_commands           | 1          |
  19313.      | Handler_delete           | 462604     |
  19314.      | Handler_read_first       | 105881     |
  19315.      | Handler_read_key         | 27820558   |
  19316.      | Handler_read_next        | 390681754  |
  19317.      | Handler_read_prev        | 6022500    |
  19318.      | Handler_read_rnd         | 30546748   |
  19319.      | Handler_read_rnd_next    | 246216530  |
  19320.      | Handler_update           | 16945404   |
  19321.      | Handler_write            | 60356676   |
  19322.      | Key_blocks_used          | 14955      |
  19323.      | Key_read_requests        | 96854827   |
  19324.      | Key_reads                | 162040     |
  19325.      | Key_write_requests       | 7589728    |
  19326.      | Key_writes               | 3813196    |
  19327.      | Max_used_connections     | 0          |
  19328.      | Not_flushed_delayed_rows | 0          |
  19329.      | Not_flushed_key_blocks   | 0          |
  19330.      | Open_files               | 2          |
  19331.      | Open_streams             | 0          |
  19332.      | Open_tables              | 1          |
  19333.      | Opened_tables            | 44600      |
  19334.      | Qcache_free_blocks       | 36         |
  19335.      | Qcache_free_memory       | 138488     |
  19336.      | Qcache_hits              | 79570      |
  19337.      | Qcache_inserts           | 27087      |
  19338.      | Qcache_lowmem_prunes     | 3114       |
  19339.      | Qcache_not_cached        | 22989      |
  19340.      | Qcache_queries_in_cache  | 415        |
  19341.      | Qcache_total_blocks      | 912        |
  19342.      | Questions                | 2026873    |
  19343.      | Select_full_join         | 0          |
  19344.      | Select_full_range_join   | 0          |
  19345.      | Select_range             | 99646      |
  19346.      | Select_range_check       | 0          |
  19347.      | Select_scan              | 30802      |
  19348.      | Slave_open_temp_tables   | 0          |
  19349.      | Slave_running            | OFF        |
  19350.      | Slow_launch_threads      | 0          |
  19351.      | Slow_queries             | 0          |
  19352.      | Sort_merge_passes        | 30         |
  19353.      | Sort_range               | 500        |
  19354.      | Sort_rows                | 30296250   |
  19355.      | Sort_scan                | 4650       |
  19356.      | Table_locks_immediate    | 1920382    |
  19357.      | Table_locks_waited       | 0          |
  19358.      | Threads_cached           | 0          |
  19359.      | Threads_connected        | 1          |
  19360.      | Threads_created          | 30022      |
  19361.      | Threads_running          | 1          |
  19362.      | Uptime                   | 80380      |
  19363.      +--------------------------+------------+
  19364.  
  19365. Many status variables are reset to 0 by the `FLUSH STATUS' statement.
  19366.  
  19367. The status variables have the following meanings.  The `Com_XXX'
  19368. statement counter variables were added beginning with MySQL 3.23.47. The
  19369. `Qcache_XXX' query cache variables were added beginning with MySQL
  19370. 4.0.1. Otherwise, variables with no version indicated have been present
  19371. since at least MySQL 3.22.
  19372.  
  19373. `Aborted_clients'
  19374.      The number of connections that were aborted because the client
  19375.      died without closing the connection properly.  *Note Communication
  19376.      errors::.
  19377.  
  19378. `Aborted_connects'
  19379.      The number of tries to connect to the MySQL server that failed.
  19380.      *Note Communication errors::.
  19381.  
  19382. `Binlog_cache_disk_use'
  19383.      The number of transactions that used the temporary binary log
  19384.      cache but that exceeded the value of `binlog_cache_size' and used
  19385.      a temporary file to store statements from the transaction.  This
  19386.      variable was added in MySQL 4.1.2.
  19387.  
  19388. `Binlog_cache_use'
  19389.      The number of transactions that used the temporary binary log
  19390.      cache.  This variable was added in MySQL 4.1.2.
  19391.  
  19392. `Bytes_received'
  19393.      The number of bytes received from all clients.  This variable was
  19394.      added in MySQL 3.23.7.
  19395.  
  19396. `Bytes_sent'
  19397.      The number of bytes sent to all clients.  This variable was added
  19398.      in MySQL 3.23.7.
  19399.  
  19400. `Com_XXX'
  19401.      The number of times each XXX statement has been executed.  There
  19402.      is one status variable for each type of statement. For example,
  19403.      `Com_delete' and `Com_insert' count `DELETE' and `INSERT'
  19404.      statements.
  19405.  
  19406. `Connections'
  19407.      The number of connection attempts (successful or not) to the MySQL
  19408.      server.
  19409.  
  19410. `Created_tmp_disk_tables'
  19411.      The number of temporary tables on disk created automatically by
  19412.      the server while executing statements.  This variable was added in
  19413.      MySQL 3.23.24.
  19414.  
  19415. `Created_tmp_files'
  19416.      How many temporary files `mysqld' has created.  This variable was
  19417.      added in MySQL 3.23.28.
  19418.  
  19419. `Created_tmp_tables'
  19420.      The number of in-memory temporary tables created automatically by
  19421.      the server while executing statements.  If
  19422.      `Created_tmp_disk_tables' is big, you may want to increase the
  19423.      `tmp_table_size' value to cause temporary tables to be memory-based
  19424.      instead of disk-based.
  19425.  
  19426. `Delayed_errors'
  19427.      The number of rows written with `INSERT DELAYED' for which some
  19428.      error occurred (probably `duplicate key').
  19429.  
  19430. `Delayed_insert_threads'
  19431.      The number of `INSERT DELAYED' handler threads in use.
  19432.  
  19433. `Delayed_writes'
  19434.      The number of `INSERT DELAYED' rows written.
  19435.  
  19436. `Flush_commands'
  19437.      The number of executed `FLUSH' statements.
  19438.  
  19439. `Handler_commit'
  19440.      The number of internal `COMMIT' statements.  This variable was
  19441.      added in MySQL 4.0.2.
  19442.  
  19443. `Handler_discover'
  19444.      The MySQL server can ask the `NDB Cluster' storage engine if it
  19445.      knows about a table with a given name. This is called discovery.
  19446.      `Handler_discover' indicates the number of time tables have been
  19447.      discovered.  This variable was added in MySQL 4.1.2.
  19448.  
  19449. `Handler_delete'
  19450.      The number of times a row was deleted from a table.
  19451.  
  19452. `Handler_read_first'
  19453.      The number of times the first entry was read from an index.  If
  19454.      this is high, it suggests that the server is doing a lot of full
  19455.      index scans; for example, `SELECT col1 FROM foo', assuming that
  19456.      `col1' is indexed.
  19457.  
  19458. `Handler_read_key'
  19459.      The number of requests to read a row based on a key. If this is
  19460.      high, it is a good indication that your queries and tables are
  19461.      properly indexed.
  19462.  
  19463. `Handler_read_next'
  19464.      The number of requests to read the next row in key order. This
  19465.      will be incremented if you are querying an index column with a
  19466.      range constraint or if you are doing an index scan.
  19467.  
  19468. `Handler_read_prev'
  19469.      The number of requests to read the previous row in key order.
  19470.      This read method is mainly used to optimize `ORDER BY ... DESC'.
  19471.      This variable was added in MySQL 3.23.6.
  19472.  
  19473. `Handler_read_rnd'
  19474.      The number of requests to read a row based on a fixed position.
  19475.      This will be high if you are doing a lot of queries that require
  19476.      sorting of the result.  You probably have a lot of queries that
  19477.      require MySQL to scan whole tables or you have joins that don't
  19478.      use keys properly.
  19479.  
  19480. `Handler_read_rnd_next'
  19481.      The number of requests to read the next row in the data file.
  19482.      This will be high if you are doing a lot of table scans. Generally
  19483.      this suggests that your tables are not properly indexed or that
  19484.      your queries are not written to take advantage of the indexes you
  19485.      have.
  19486.  
  19487. `Handler_rollback'
  19488.      The number of internal `ROLLBACK' statements.  This variable was
  19489.      added in MySQL 4.0.2.
  19490.  
  19491. `Handler_update'
  19492.      The number of requests to update a row in a table.
  19493.  
  19494. `Handler_write'
  19495.      The number of requests to insert a row in a table.
  19496.  
  19497. `Key_blocks_not_flushed'
  19498.      The number of key blocks in the key cache that have changed but
  19499.      haven't yet been flushed to disk.  This variable was added in
  19500.      MySQL 4.1.1.  It used to be known as `Not_flushed_key_blocks'.
  19501.  
  19502. `Key_blocks_unused'
  19503.      This variable was added in MySQL 4.1.2.  *Note Server system
  19504.      variables::.
  19505.  
  19506. `Key_blocks_used'
  19507.      The number of used blocks in the key cache.  You can use this
  19508.      value to determine how much of the key cache is in use; see the
  19509.      discussion of `key_buffer_size' in *Note Server system variables::.
  19510.  
  19511. `Key_read_requests'
  19512.      The number of requests to read a key block from the cache.
  19513.  
  19514. `Key_reads'
  19515.      The number of physical reads of a key block from disk.  If
  19516.      `Key_reads' is big, then your `key_buffer_size' value is probably
  19517.      too small.  The cache miss rate can be calculated as
  19518.      `Key_reads'/`Key_read_requests'.
  19519.  
  19520. `Key_write_requests'
  19521.      The number of requests to write a key block to the cache.
  19522.  
  19523. `Key_writes'
  19524.      The number of physical writes of a key block to disk.
  19525.  
  19526. `Last_query_cost'
  19527.      The total cost of the last compiled query as computed by the query
  19528.      optimizer. Useful for comparing the cost of different query plans
  19529.      for the same query. The default value of -1 means that no query
  19530.      has been compiled yet. This variable was added in MySQL 5.0.1.
  19531.  
  19532. `Max_used_connections'
  19533.      The maximum number of connections that have been in use
  19534.      simultaneously since the server started.
  19535.  
  19536. `Not_flushed_delayed_rows'
  19537.      The number of rows waiting to be written in `INSERT DELAY' queues.
  19538.  
  19539. `Not_flushed_key_blocks'
  19540.      The old name for `Key_blocks_not_flushed' before MySQL 4.1.1.
  19541.  
  19542. `Open_files'
  19543.      The number of files that are open.
  19544.  
  19545. `Open_streams'
  19546.      The number of streams that are open (used mainly for logging).
  19547.  
  19548. `Open_tables'
  19549.      The number of tables that are open.
  19550.  
  19551. `Opened_tables'
  19552.      The number of tables that have been opened.  If `Opened_tables' is
  19553.      big, your `table_cache' value is probably too small.
  19554.  
  19555. `Qcache_free_blocks'
  19556.      The number of free memory blocks in query cache.
  19557.  
  19558. `Qcache_free_memory'
  19559.      The amount of free memory for query cache.
  19560.  
  19561. `Qcache_hits'
  19562.      The number of cache hits.
  19563.  
  19564. `Qcache_inserts'
  19565.      The number of queries added to the cache.
  19566.  
  19567. `Qcache_lowmem_prunes'
  19568.      The number of queries that were deleted from the cache because of
  19569.      low memory.
  19570.  
  19571. `Qcache_not_cached'
  19572.      The number of non-cached queries (not cachable, or due to
  19573.      `query_cache_type').
  19574.  
  19575. `Qcache_queries_in_cache'
  19576.      The number of queries registered in the cache.
  19577.  
  19578. `Qcache_total_blocks'
  19579.      The total number of blocks in the query cache.
  19580.  
  19581. `Questions'
  19582.      The number of queries that have been sent to the server.
  19583.  
  19584. `Rpl_status'
  19585.      The status of failsafe replication (not yet implemented).
  19586.  
  19587. `Select_full_join'
  19588.      The number of joins that do not use indexes.  If this value is not
  19589.      0, you should carefully check the indexes of your tables.  This
  19590.      variable was added in MySQL 3.23.25.
  19591.  
  19592. `Select_full_range_join'
  19593.      The number of joins that used a range search on a reference table.
  19594.      This variable was added in MySQL 3.23.25.
  19595.  
  19596. `Select_range'
  19597.      The number of joins that used ranges on the first table. (It's
  19598.      normally not critical even if this is big.)  This variable was
  19599.      added in MySQL 3.23.25.
  19600.  
  19601. `Select_range_check'
  19602.      The number of joins without keys that check for key usage after
  19603.      each row.  (If this is not 0, you should carefully check the
  19604.      indexes of your tables.)  This variable was added in MySQL 3.23.25.
  19605.  
  19606. `Select_scan'
  19607.      The number of joins that did a full scan of the first table.  This
  19608.      variable was added in MySQL 3.23.25.
  19609.  
  19610. `Slave_open_temp_tables'
  19611.      The number of temporary tables currently open by the slave SQL
  19612.      thread.  This variable was added in MySQL 3.23.29.
  19613.  
  19614. `Slave_running'
  19615.      This is `ON' if this server is a slave that is connected to a
  19616.      master.  This variable was added in MySQL 3.23.16.
  19617.  
  19618. `Slow_launch_threads'
  19619.      The number of threads that have taken more than `slow_launch_time'
  19620.      seconds to create.  This variable was added in MySQL 3.23.15.
  19621.  
  19622. `Slow_queries'
  19623.      The number of queries that have taken more than `long_query_time'
  19624.      seconds. *Note Slow query log::.
  19625.  
  19626. `Sort_merge_passes'
  19627.      The number of merge passes the sort algorithm has had to do. If
  19628.      this value is large, you should consider increasing the value of
  19629.      the `sort_buffer_size' system variable.  This variable was added
  19630.      in MySQL 3.23.28.
  19631.  
  19632. `Sort_range'
  19633.      The number of sorts that were done with ranges.  This variable was
  19634.      added in MySQL 3.23.25.
  19635.  
  19636. `Sort_rows'
  19637.      The number of sorted rows.  This variable was added in MySQL
  19638.      3.23.25.
  19639.  
  19640. `Sort_scan'
  19641.      The number of sorts that were done by scanning the table.  This
  19642.      variable was added in MySQL 3.23.25.
  19643.  
  19644. `Ssl_XXX'
  19645.      Variables used for SSL connections.  These variables were added in
  19646.      MySQL 4.0.0.
  19647.  
  19648. `Table_locks_immediate'
  19649.      The number of times that a table lock was acquired immediately.
  19650.      This variable was added as of MySQL 3.23.33.
  19651.  
  19652. `Table_locks_waited'
  19653.      The number of times that a table lock could not be acquired
  19654.      immediately and a wait was needed. If this is high, and you have
  19655.      performance problems, you should first optimize your queries, and
  19656.      then either split your table or tables or use replication.  This
  19657.      variable was added as of MySQL 3.23.33.
  19658.  
  19659. `Threads_cached'
  19660.      The number of threads in the thread cache.  This variable was
  19661.      added in MySQL 3.23.17.
  19662.  
  19663. `Threads_connected'
  19664.      The number of currently open connections.
  19665.  
  19666. `Threads_created'
  19667.      The number of threads created to handle connections.  If
  19668.      `Threads_created' is big, you may want to increase the
  19669.      `thread_cache_size' value.  The cache hit rate can be calculated
  19670.      as `Threads_created'/`Connections'.  This variable was added in
  19671.      MySQL 3.23.31.
  19672.  
  19673. `Threads_running'
  19674.      The number of threads that are not sleeping.
  19675.  
  19676. `Uptime'
  19677.      The number of seconds the server has been up.
  19678.  
  19679. The MySQL Server Shutdown Process
  19680. =================================
  19681.  
  19682. The server shutdown process can be summarized like this:
  19683.  
  19684.   1. The shutdown process is initiated
  19685.  
  19686.   2. The server creates a shutdown thread if necessary
  19687.  
  19688.   3. The server stops accepting new connections
  19689.  
  19690.   4. The server terminates current activity
  19691.  
  19692.   5. Storage engines are shut down or closed
  19693.  
  19694.   6. The server exits
  19695.  
  19696. A more detailed description of the process follows:
  19697.  
  19698.   1. The shutdown process is initiated
  19699.  
  19700.      Server shutdown can be initiated several ways. For example, a user
  19701.      with the `SHUTDOWN' privilege can execute a `mysqladmin shutdown'
  19702.      command. `mysqladmin' can be used on any platform supported by
  19703.      MySQL. Other operating sytem-specific shutdown initiation methods
  19704.      are possible as well: The server shuts down on Unix when it
  19705.      receives a `SIGTERM' signal. A server running as a service on
  19706.      Windows shuts down when the services manager tells it to.
  19707.  
  19708.   2. The server creates a shutdown thread if necessary
  19709.  
  19710.      Depending on how shutdown was initiated, the server might create a
  19711.      thread to handle the shutdown process.  If shutdown was requested
  19712.      by a client, a shutdown thread is created.  If shutdown is the
  19713.      result of receiving a `SIGTERM' signal, the signal thread might
  19714.      handle shutdown itself, or it might create a separate thread to do
  19715.      so.  If the server tries to create a shutdown thread and cannot
  19716.      (for example, if memory is exhausted), it issues a diagnostic
  19717.      message that will appear in the error log:
  19718.  
  19719.           Error: Can't create thread to kill server
  19720.  
  19721.   3. The server stops accepting new connections
  19722.  
  19723.      To prevent new activity from being initiated during shutdown, the
  19724.      server stops accepting new client connections. It does this by
  19725.      closing the network connections to which it normally listens for
  19726.      connections: the TCP/IP port, the Unix socket file, the Windows
  19727.      named pipe.
  19728.  
  19729.   4. The server terminates current activity
  19730.  
  19731.      For each thread that is associated with a client connection, the
  19732.      connection to the client is broken and the thread is marked as
  19733.      killed. Threads die when they notice that they are so marked.
  19734.      Threads for idle connections die quickly. Threads that currently
  19735.      are processing queries check their state periodically and take
  19736.      longer to die.  For additional information about thread
  19737.      termination, see *Note `KILL': KILL, in particular for the
  19738.      instructions about killed `REPAIR TABLE' or `OPTIMIZE TABLE'
  19739.      operations on `MyISAM' tables.
  19740.  
  19741.      For threads that have an open transaction, the tranaction is
  19742.      rolled back.  Note that if a thread is updating a
  19743.      non-transactional table, an operation such as a multiple-row
  19744.      `UPDATE' or `INSERT' may leave the table partially updated,
  19745.      because the operation can terminate before completion.
  19746.  
  19747.      If the server is a master replication server, threads associated
  19748.      with currently connected slaves are treated like other client
  19749.      threads. That is, each one is marked as killed and exits when it
  19750.      next checks its state.
  19751.  
  19752.      If the server is a slave replication server, the I/O and SQL
  19753.      threads, if active, are stopped before client threads are marked
  19754.      as killed. The SQL thread is allowed to finish its current
  19755.      statement (to avoid causing replication problems) then stops. If
  19756.      the SQL thread was in the middle of a transaction at this point,
  19757.      the transaction is rolled back.
  19758.  
  19759.   5. Storage engines are shut down or closed
  19760.  
  19761.      At this stage, the table cache is flushed and all open tables are
  19762.      closed.
  19763.  
  19764.      Each storage engine performs any actions necessary for tables that
  19765.      it manages.  For example, MyISAM flushes any pending index writes
  19766.      for a table.  InnoDB flushes its buffer pool to disk, writes the
  19767.      current LSN to the tablespace, and terminates its own internal
  19768.      threads.
  19769.  
  19770.   6. The server exits
  19771.  
  19772.  
  19773. General Security Issues
  19774. =======================
  19775.  
  19776. This section describes some general security issues to be aware of and
  19777. what you can do to make your MySQL installation more secure against
  19778. attack or misuse. For information specifically about the access control
  19779. system that MySQL uses for setting up user accounts and checking
  19780. database access, see *Note Privilege system::.
  19781.  
  19782. General Security Guidelines
  19783. ---------------------------
  19784.  
  19785. Anyone using MySQL on a computer connected to the Internet should read
  19786. this section to avoid the most common security mistakes.
  19787.  
  19788. In discussing security, we emphasize the necessity of fully protecting
  19789. the entire server host (not just the MySQL server) against all types of
  19790. applicable attacks: eavesdropping, altering, playback, and denial of
  19791. service. We do not cover all aspects of availability and fault tolerance
  19792. here.
  19793.  
  19794. MySQL uses security based on Access Control Lists (ACLs) for all
  19795. connections, queries, and other operations that users can attempt to
  19796. perform. There is also some support for SSL-encrypted connections
  19797. between MySQL clients and servers. Many of the concepts discussed here
  19798. are not specific to MySQL at all; the same general ideas apply to
  19799. almost all applications.
  19800.  
  19801. When running MySQL, follow these guidelines whenever possible:
  19802.  
  19803.    * *Do not ever give anyone (except MySQL `root' accounts) access to
  19804.      the `user' table in the `mysql' database!*  This is critical.
  19805.      *The encrypted password is the real password in MySQL.* Anyone who
  19806.      knows the password that is listed in the `user' table and has
  19807.      access to the host listed for the account *can easily log in as
  19808.      that user*.
  19809.  
  19810.    * Learn the MySQL access privilege system. The `GRANT' and `REVOKE'
  19811.      statements are used for controlling access to MySQL. Do not grant
  19812.      any more privileges than necessary. Never grant privileges to all
  19813.      hosts.
  19814.  
  19815.      Checklist:
  19816.         - Try `mysql -u root'. If you are able to connect successfully
  19817.           to the server without being asked for a password, you have
  19818.           problems. Anyone can connect to your MySQL server as the MySQL
  19819.           `root' user with full privileges!  Review the MySQL
  19820.           installation instructions, paying particular attention to the
  19821.           information about setting a `root' password.  *Note Default
  19822.           privileges::.
  19823.  
  19824.         - Use the `SHOW GRANTS' statement and check to see who has
  19825.           access to what.  Then use the `REVOKE' statement to remove
  19826.           those privileges that are not necessary.
  19827.  
  19828.    * Do not store any plain-text passwords in your database. If your
  19829.      computer becomes compromised, the intruder can take the full list
  19830.      of passwords and use them. Instead, use `MD5()', `SHA1()', or some
  19831.      other one-way hashing function.
  19832.  
  19833.    * Do not choose passwords from dictionaries. There are special
  19834.      programs to break them. Even passwords like "xfish98" are very
  19835.      bad.  Much better is "duag98" which contains the same word "fish"
  19836.      but typed one key to the left on a standard QWERTY keyboard.
  19837.      Another method is to use "Mhall" which is taken from the first
  19838.      characters of each word in the sentence "Mary had a little lamb."
  19839.      This is easy to remember and type, but difficult to guess for
  19840.      someone who does not know it.
  19841.  
  19842.    * Invest in a firewall. This protects you from at least 50% of all
  19843.      types of exploits in any software. Put MySQL behind the firewall
  19844.      or in a demilitarized zone (DMZ).
  19845.  
  19846.      Checklist:
  19847.         - Try to scan your ports from the Internet using a tool such as
  19848.           `nmap'. MySQL uses port 3306 by default. This port should not
  19849.           be accessible from untrusted hosts. Another simple way to
  19850.           check whether or not your MySQL port is open is to try the
  19851.           following command from some remote machine, where
  19852.           `server_host' is the host on which your MySQL server runs:
  19853.  
  19854.                shell> telnet server_host 3306
  19855.  
  19856.           If you get a connection and some garbage characters, the port
  19857.           is open, and should be closed on your firewall or router,
  19858.           unless you really have a good reason to keep it open. If
  19859.           `telnet' just hangs or the connection is refused, everything
  19860.           is OK; the port is blocked.
  19861.  
  19862.    * Do not trust any data entered by users of your applications. They
  19863.      can try to trick your code by entering special or escaped
  19864.      character sequences in Web forms, URLs, or whatever application
  19865.      you have built. Be sure that your application remains secure if a
  19866.      user enters something like "`; DROP DATABASE mysql;'". This is an
  19867.      extreme example, but large security leaks and data loss might
  19868.      occur as a result of hackers using similar techniques, if you do
  19869.      not prepare for them.
  19870.  
  19871.      A common mistake is to protect only string data values.  Remember
  19872.      to check numeric data as well.  If an application generates a
  19873.      query such as `SELECT * FROM table WHERE ID=234' when a user
  19874.      enters the value `234', the user can enter the value `234 OR 1=1'
  19875.      to cause the application to generate the query `SELECT * FROM
  19876.      table WHERE ID=234 OR 1=1'.  As a result, the server retrieves
  19877.      every record in the table.  This exposes every record and causes
  19878.      excessive server load.  The simplest way to protect from this type
  19879.      of attack is to use apostrophes around the numeric constants:
  19880.      `SELECT * FROM table WHERE ID='234''. If the user enters extra
  19881.      information, it all becomes part of the string. In numeric context,
  19882.      MySQL automatically converts this string to a number and strips
  19883.      any trailing non-numeric characters from it.
  19884.  
  19885.      Sometimes people think that if a database contains only publicly
  19886.      available data, it need not be protected. This is incorrect.  Even
  19887.      if it is allowable to display any record in the database, you
  19888.      should still protect against denial of service attacks (for
  19889.      example, those that are based on the technique in the preceding
  19890.      paragraph that causes the server to waste resources). Otherwise,
  19891.      your server becomes unresponsive to legitimate users.
  19892.  
  19893.      Checklist:
  19894.         - Try to enter `'' and `"' in all your Web forms. If you get
  19895.           any kind of MySQL error, investigate the problem right away.
  19896.  
  19897.         - Try to modify any dynamic URLs by adding `%22' (`"'), `%23'
  19898.           (`#'), and `%27' (`'') in the URL.
  19899.  
  19900.         - Try to modify data types in dynamic URLs from numeric ones to
  19901.           character ones containing characters from previous examples.
  19902.           Your application should be safe against this and similar
  19903.           attacks.
  19904.  
  19905.         - Try to enter characters, spaces, and special symbols rather
  19906.           than numbers in numeric fields. Your application should
  19907.           remove them before passing them to MySQL or else generate an
  19908.           error. Passing unchecked values to MySQL is very dangerous!
  19909.  
  19910.         - Check data sizes before passing them to MySQL.
  19911.  
  19912.         - Consider having your application connect to the database
  19913.           using a different username than the one you use for
  19914.           administrative purposes. Do not give your applications any
  19915.           access privileges they do not need.
  19916.  
  19917.    * Many application programming interfaces provide a means of
  19918.      escaping special characters in data values. Properly used, this
  19919.      prevents application users from entering values that cause the
  19920.      application to generate statements that have a different effect
  19921.      than you intend:
  19922.         - MySQL C API: Use the `mysql_real_escape_string()' API call.
  19923.  
  19924.         - MySQL++: Use the `escape' and `quote' modifiers for query
  19925.           streams.
  19926.  
  19927.         - PHP: Use the `mysql_escape_string()' function, which is based
  19928.           on the function of the same name in the MySQL C API.  Prior
  19929.           to PHP 4.0.3, use  `addslashes()' instead.
  19930.  
  19931.         - Perl DBI: Use the `quote()' method or use placeholders.
  19932.  
  19933.         - Java JDBC: Use a `PreparedStatement' object and placeholders.
  19934.  
  19935.      Other programming interfaces might have similar capabilities.
  19936.  
  19937.    * Do not transmit plain (unencrypted) data over the Internet. This
  19938.      information is accessible to everyone who has the time and ability
  19939.      to intercept it and use it for their own purposes. Instead, use an
  19940.      encrypted protocol such as SSL or SSH. MySQL supports internal SSL
  19941.      connections as of Version 4.0.0.  SSH port-forwarding can be used
  19942.      to create an encrypted (and compressed) tunnel for the
  19943.      communication.
  19944.  
  19945.    * Learn to use the `tcpdump' and `strings' utilities. For most cases,
  19946.      you can check whether MySQL data streams are unencrypted by
  19947.      issuing a command like the following:
  19948.  
  19949.           shell> tcpdump -l -i eth0 -w - src or dst port 3306 | strings
  19950.  
  19951.      (This works under Linux and should work with small modifications
  19952.      under other systems.)  Warning: If you do not see plaintext data,
  19953.      this doesn't always mean that the information actually is
  19954.      encrypted. If you need high security, you should consult with a
  19955.      security expert.
  19956.  
  19957. Making MySQL Secure Against Attackers
  19958. -------------------------------------
  19959.  
  19960. When you connect to a MySQL server, you should use a password.  The
  19961. password is not transmitted in clear text over the connection. Password
  19962. handling during the client connection sequence was upgraded in MySQL
  19963. 4.1.1 to be very secure.  If you are using an older version of MySQL,
  19964. or are still using pre-4.1.1-style passwords, the encryption algorithm
  19965. is less strong and with some effort a clever attacker who can sniff the
  19966. traffic between the client and the server can crack the password.  (See
  19967. *Note Password hashing:: for a discussion of the different password
  19968. handling methods.)  If the connection between the client and the server
  19969. goes through an untrusted network, you should use an SSH tunnel to
  19970. encrypt the communication.
  19971.  
  19972. All other information is transferred as text that can be read by anyone
  19973. who is able to watch the connection.  If you are concerned about this,
  19974. you can use the compressed protocol (in MySQL 3.22 and above) to make
  19975. traffic much more difficult to decipher.  To make the connection even
  19976. more secure, you should use SSH to get an encrypted TCP/IP connection
  19977. between a MySQL server and a MySQL client.  You can find an Open Source
  19978. SSH client at `http://www.openssh.org/', and a commercial SSH client at
  19979. `http://www.ssh.com/'.
  19980.  
  19981. If you are using MySQL 4.0 or newer, you can also use internal OpenSSL
  19982. support.  *Note Secure connections::.
  19983.  
  19984. To make a MySQL system secure, you should strongly consider the
  19985. following suggestions:
  19986.  
  19987.    * Use passwords for all MySQL users. A client program does not
  19988.      necessarily know the identity of the person running it. It is
  19989.      common for client/server applications that the user can specify
  19990.      any username to the client program.  For example, anyone can use
  19991.      the `mysql' program to connect as any other person simply by
  19992.      invoking it as `mysql -u OTHER_USER DB_NAME' if OTHER_USER has no
  19993.      password. If all users have a password, connecting using another
  19994.      user's account becomes much more difficult.
  19995.  
  19996.      To change the password for a user, use the `SET PASSWORD'
  19997.      statement.  It is also possible to update the `user' table in the
  19998.      `mysql' database directly.  For example, to change the password of
  19999.      all MySQL accounts that have a username of `root', do this:
  20000.  
  20001.           shell> mysql -u root
  20002.           mysql> UPDATE mysql.user SET Password=PASSWORD('NEWPWD')
  20003.               -> WHERE User='root';
  20004.           mysql> FLUSH PRIVILEGES;
  20005.  
  20006.    * Don't run the MySQL server as the Unix `root' user.  This is very
  20007.      dangerous, because any user with the `FILE' privilege will be able
  20008.      to create files as `root' (for example, `~root/.bashrc'). To
  20009.      prevent this, `mysqld' refuses to run as `root' unless that is
  20010.      specified explicitly using a `--user=root' option.
  20011.  
  20012.      `mysqld' can be run as an ordinary unprivileged user instead.  You
  20013.      can also create a separate Unix account named `mysql' to make
  20014.      everything even more secure. Use the account only for
  20015.      administering MySQL.  To start `mysqld' as another Unix user, add
  20016.      a `user' option that specifies the username to the `[mysqld]'
  20017.      group of the `/etc/my.cnf' option file or the `my.cnf' option file
  20018.      in the server's data directory. For example:
  20019.  
  20020.           [mysqld]
  20021.           user=mysql
  20022.  
  20023.      This causes the server to start as the designated user whether you
  20024.      start it manually or by using `mysqld_safe' or `mysql.server'.
  20025.      For more details, see *Note Changing MySQL user::.
  20026.  
  20027.      Running `mysqld' as a Unix user other than `root' does not mean
  20028.      that you need to change the `root' username in the `user' table.
  20029.      Usernames for MySQL accounts have nothing to do with usernames for
  20030.      Unix accounts.
  20031.  
  20032.    * Don't allow the use of symlinks to tables. (This can be disabled
  20033.      with the `--skip-symbolic-links' option.) This is especially
  20034.      important if you run `mysqld' as `root', because anyone that has
  20035.      write access to the server's data directory then could delete any
  20036.      file in the system!  *Note Symbolic links to tables::.
  20037.  
  20038.    * Make sure that the only Unix user with read or write privileges in
  20039.      the database directories is the user that `mysqld' runs as.
  20040.  
  20041.    * Don't grant the `PROCESS' or `SUPER' privilege to
  20042.      non-administrative users.  The output of `mysqladmin processlist'
  20043.      shows the text of the currently executing queries, so any user who
  20044.      is allowed to execute that command might be able to see if another
  20045.      user issues an `UPDATE user SET password=PASSWORD('not_secure')'
  20046.      query.
  20047.  
  20048.      `mysqld' reserves an extra connection for users who have the
  20049.      `SUPER' privilege (`PROCESS' before MySQL 4.0.2), so that a MySQL
  20050.      `root' user can log in and check server activity even if all normal
  20051.      connections are in use.
  20052.  
  20053.      The `SUPER' privilege can be used to terminate client connections,
  20054.      change server operation by changing the value of system variables,
  20055.      and control replication servers.
  20056.  
  20057.    * Don't grant the `FILE' privilege to non-administrative users.  Any
  20058.      user that has this privilege can write a file anywhere in the
  20059.      filesystem with the privileges of the `mysqld' daemon!  To make
  20060.      this a bit safer, files generated with `SELECT ... INTO OUTFILE'
  20061.      will not overwrite existing files and are writable by everyone.
  20062.  
  20063.      The `FILE' privilege may also be used to read any file that is
  20064.      world-readable or accessible to the Unix user that the server runs
  20065.      as.  With this privilege, you can read any file into a database
  20066.      table.  This could be abused, for example, by using `LOAD DATA' to
  20067.      load `/etc/passwd' into a table, which then can be displayed with
  20068.      `SELECT'.
  20069.  
  20070.    * If you don't trust your DNS, you should use IP numbers rather than
  20071.      hostnames in the grant tables. In any case, you should be very
  20072.      careful about creating grant table entries using hostname values
  20073.      that contain wildcards!
  20074.  
  20075.    * If you want to restrict the number of connections allowed to a
  20076.      single account, you can do so by setting the
  20077.      `max_user_connections' variable in `mysqld'.  The `GRANT'
  20078.      statement also supports resource control options for limiting the
  20079.      extent of server use allowed to an account.
  20080.  
  20081. Startup Options for `mysqld' Concerning Security
  20082. ------------------------------------------------
  20083.  
  20084. The following `mysqld' options affect security:
  20085.  
  20086. `--local-infile[={0|1}]'
  20087.      If you start the server with `--local-infile=0', clients cannot use
  20088.      `LOCAL' in `LOAD DATA' statements.  *Note `LOAD DATA LOCAL': LOAD
  20089.      DATA LOCAL.
  20090.  
  20091. `--safe-show-database'
  20092.      With this option, the `SHOW DATABASES' statement displays the names
  20093.      of only those databases for which the user has some kind of
  20094.      privilege.  As of MySQL 4.0.2, this option is deprecated and
  20095.      doesn't do anything (it is enabled by default), because there is
  20096.      now a `SHOW DATABASES' privilege that can be used to control
  20097.      access to database names on a per-account basis. *Note `GRANT':
  20098.      GRANT.
  20099.  
  20100. `--safe-user-create'
  20101.      If this is enabled, a user cannot create new users with the `GRANT'
  20102.      statement unless the user has the `INSERT' privilege for the
  20103.      `mysql.user' table.  If you want a user to have the ability to
  20104.      create new users with those privileges that the user has right to
  20105.      grant, you should grant the user the following privilege:
  20106.  
  20107.           mysql> GRANT INSERT(user) ON mysql.user TO 'USER_NAME'@'HOST_NAME';
  20108.  
  20109.      This will ensure that the user can't change any privilege columns
  20110.      directly, but has to use the `GRANT' statement to give privileges
  20111.      to other users.
  20112.  
  20113. `--secure-auth'
  20114.      Disallow authentication for accounts that have old (pre-4.1)
  20115.      passwords.  This option is available as of MySQL 4.1.1.
  20116.  
  20117. `--skip-grant-tables'
  20118.      This option causes the server not to use the privilege system at
  20119.      all. This gives everyone _full access_ to all databases!  (You can
  20120.      tell a running server to start using the grant tables again by
  20121.      executing a `mysqladmin flush-privileges' or `mysqladmin reload'
  20122.      command, or by issuing a `FLUSH PRIVILEGES' statement.)
  20123.  
  20124. `--skip-name-resolve'
  20125.      Hostnames are not resolved.  All `Host' column values in the grant
  20126.      tables must be IP numbers or `localhost'.
  20127.  
  20128. `--skip-networking'
  20129.      Don't allow TCP/IP connections over the network.  All connections
  20130.      to `mysqld' must be made via Unix socket files.  This option is
  20131.      unsuitable when using a MySQL version prior to 3.23.27 with the
  20132.      MIT-pthreads package, because Unix socket files were not supported
  20133.      by MIT-pthreads at that time.
  20134.  
  20135. `--skip-show-database'
  20136.      With this option, the `SHOW DATABASES' statement is allowed only to
  20137.      users who have the `SHOW DATABASES' privilege, and the statement
  20138.      displays all database names.  Without this option, `SHOW
  20139.      DATABASES' is allowed to all users, but displays each database
  20140.      name only if the user has the `SHOW DATABASES' privilege or some
  20141.      privilege for the database.
  20142.  
  20143. Security Issues with `LOAD DATA LOCAL'
  20144. --------------------------------------
  20145.  
  20146. The `LOAD DATA' statement can load a file that is located on the server
  20147. host, or it can load a file that is located on the client host when the
  20148. `LOCAL' keyword is specified.
  20149.  
  20150. There are two potential security issues with supporting the `LOCAL'
  20151. version of `LOAD DATA' statements:
  20152.  
  20153.    * The transfer of the file from the client host to the server host
  20154.      is initiated by the MySQL server. In theory, a patched server
  20155.      could be built that would tell the client program to transfer a
  20156.      file of the server's choosing rather than the file named by the
  20157.      client in the `LOAD DATA' statement. Such a server could access
  20158.      any file on the client host to which the client user has read
  20159.      access.
  20160.  
  20161.    * In a Web environment where the clients are connecting from a Web
  20162.      server, a user could use `LOAD DATA LOCAL' to read any files that
  20163.      the Web server process has read access to (assuming that a user
  20164.      could run any command against the SQL server). In this
  20165.      environment, the client with respect to the MySQL server actually
  20166.      is the Web server, not the program being run by the user
  20167.      connecting to the Web server.
  20168.  
  20169.  
  20170. To deal with these problems, we changed how `LOAD DATA LOCAL' is
  20171. handled as of MySQL 3.23.49 and MySQL 4.0.2 (4.0.13 on Windows):
  20172.  
  20173.    * By default, all MySQL clients and libraries in binary
  20174.      distributions are compiled with the `--enable-local-infile'
  20175.      option, to be compatible with MySQL 3.23.48 and before.
  20176.  
  20177.    * If you build MySQL from source but don't use the
  20178.      `--enable-local-infile' option to `configure', `LOAD DATA LOCAL'
  20179.      cannot be used by any client unless it is written explicitly to
  20180.      invoke `mysql_options(... MYSQL_OPT_LOCAL_INFILE, 0)'.  *Note
  20181.      `mysql_options()': mysql_options.
  20182.  
  20183.    * You can disable all `LOAD DATA LOCAL' commands from the server side
  20184.      by starting `mysqld' with the `--local-infile=0' option.
  20185.  
  20186.    * For the `mysql' command-line client, `LOAD DATA LOCAL' can be
  20187.      enabled by specifying the `--local-infile[=1]' option, or disabled
  20188.      with the `--local-infile=0' option.  Similarly, for `mysqlimport',
  20189.      the `--local' or `-L' option enables local data file loading. In
  20190.      any case, successful use of a local loading operation requires
  20191.      that the server is enabled to allow it.
  20192.  
  20193.    * If you use `LOAD DATA LOCAL' in Perl scripts or other programs that
  20194.      read the `[client]' group from option files, you can add the
  20195.      `local-infile=1' option to that group. However, to keep this from
  20196.      causing problems for programs that do not understand
  20197.      `local-infile', specify it using the `loose-' prefix:
  20198.  
  20199.           [client]
  20200.           loose-local-infile=1
  20201.  
  20202.      The `loose-' prefix can be used as of MySQL 4.0.2.
  20203.  
  20204.    * If `LOAD DATA LOCAL INFILE' is disabled, either in the server or
  20205.      the client, a client that attempts to issue such a statement
  20206.      receives the following error message:
  20207.  
  20208.           ERROR 1148: The used command is not allowed with this MySQL version
  20209.  
  20210.  
  20211. The MySQL Access Privilege System
  20212. =================================
  20213.  
  20214. MySQL has an advanced but non-standard security/privilege system.  This
  20215. section describes how it works.
  20216.  
  20217. What the Privilege System Does
  20218. ------------------------------
  20219.  
  20220. The primary function of the MySQL privilege system is to authenticate a
  20221. user connecting from a given host, and to associate that user with
  20222. privileges on a database such as `SELECT', `INSERT', `UPDATE', and
  20223. `DELETE'.
  20224.  
  20225. Additional functionality includes the ability to have an anonymous user
  20226. and to grant privileges for MySQL-specific functions such as `LOAD DATA
  20227. INFILE' and administrative operations.
  20228.  
  20229. How the Privilege System Works
  20230. ------------------------------
  20231.  
  20232. The MySQL privilege system ensures that all users may perform only the
  20233. operations allowed to them.  As a user, when you connect to a MySQL
  20234. server, your identity is determined by _the host from which you
  20235. connect_ and _the username you specify_.  The system grants privileges
  20236. according to your identity and _what you want to do_.
  20237.  
  20238. MySQL considers both your hostname and username in identifying you
  20239. because there is little reason to assume that a given username belongs
  20240. to the same person everywhere on the Internet.  For example, the user
  20241. `joe' who connects from `office.com' need not be the same person as the
  20242. user `joe' who connects from `elsewhere.com'.  MySQL handles this by
  20243. allowing you to distinguish users on different hosts that happen to
  20244. have the same name:  You can grant `joe' one set of privileges for
  20245. connections from `office.com', and a different set of privileges for
  20246. connections from `elsewhere.com'.
  20247.  
  20248. MySQL access control involves two stages:
  20249.  
  20250.    * Stage 1: The server checks whether you are even allowed to connect.
  20251.  
  20252.    * Stage 2: Assuming that you can connect, the server checks each
  20253.      statement you issue to see whether you have sufficient privileges
  20254.      to perform it.  For example, if you try to select rows from a
  20255.      table in a database or drop a table from the database, the server
  20256.      verifies that you have the `SELECT' privilege for the table or the
  20257.      `DROP' privilege for the database.
  20258.  
  20259. If your privileges are changed (either by yourself or someone else)
  20260. while you are connected, those changes will not necessarily take effect
  20261. immediately for the next statement you issue.  See *Note Privilege
  20262. changes:: for details.
  20263.  
  20264. The server stores privilege information in the grant tables of the
  20265. `mysql' database (that is, in the database named `mysql').  The MySQL
  20266. server reads the contents of these tables into memory when it starts
  20267. and re-reads them under the circumstances indicated in *Note Privilege
  20268. changes::. Access-control decisions are based on the in-memory copies
  20269. of the grant tables.
  20270.  
  20271. Normally, you manipulate the contents of the grant tables indirectly by
  20272. using the `GRANT' and `REVOKE' statements to set up accounts and control
  20273. the privileges available to each one.  *Note `GRANT': GRANT.  The
  20274. discussion here describes the underlying structure of the grant tables
  20275. and how the server uses their contents when interacting with clients.
  20276.  
  20277. The server uses the `user', `db', and `host' tables in the `mysql'
  20278. database at both stages of access control.  The columns in these grant
  20279. tables are shown here:
  20280.  
  20281. *Table Name*   *user*         *db*           *host*
  20282. *Scope         `Host'         `Host'         `Host'
  20283. columns*                                     
  20284.                `User'         `Db'           `Db'
  20285.                `Password'     `User'         
  20286. *Privilege     `Select_priv'  `Select_priv'  `Select_priv'
  20287. columns*                                     
  20288.                `Insert_priv'  `Insert_priv'  `Insert_priv'
  20289.                `Update_priv'  `Update_priv'  `Update_priv'
  20290.                `Delete_priv'  `Delete_priv'  `Delete_priv'
  20291.                `Index_priv'   `Index_priv'   `Index_priv'
  20292.                `Alter_priv'   `Alter_priv'   `Alter_priv'
  20293.                `Create_priv'  `Create_priv'  `Create_priv'
  20294.                `Drop_priv'    `Drop_priv'    `Drop_priv'
  20295.                `Grant_priv'   `Grant_priv'   `Grant_priv'
  20296.                `Create_view_priv'`Create_view_priv'`Create_view_priv'
  20297.                `Show_view_priv'`Show_view_priv'`Show_view_priv'
  20298.                `References_priv'`References_priv'`References_priv'
  20299.                `Reload_priv'                 
  20300.                `Shutdown_priv'               
  20301.                `Process_priv'                
  20302.                `File_priv'                   
  20303.                `Show_db_priv'                
  20304.                `Super_priv'                  
  20305.                `Create_tmp_table_priv'`Create_tmp_table_priv'`Create_tmp_table_priv'
  20306.                `Lock_tables_priv'`Lock_tables_priv'`Lock_tables_priv'
  20307.                `Execute_priv'                
  20308.                `Repl_slave_priv'               
  20309.                `Repl_client_priv'               
  20310.                `ssl_type'                    
  20311.                `ssl_cipher'                  
  20312.                `x509_issuer'                 
  20313.                `x509_subject'                
  20314.                `max_questions'               
  20315.                `max_updates'                 
  20316.                `max_connections'               
  20317.  
  20318. The `ssl_type', `ssl_cipher', `x509_issuer', and `x509_subject' columns
  20319. were added in MySQL 4.0.0.
  20320.  
  20321. The `Create_tmp_table_priv', `Execute_priv', `Lock_tables_priv',
  20322. `Repl_client_priv', `Repl_slave_priv', `Show_db_priv', `Super_priv',
  20323. `max_questions', `max_updates', and `max_connections' columns were
  20324. added in MySQL 4.0.2.
  20325.  
  20326. The `Create_view_priv' and `Show_view_priv' columns were added in MySQL
  20327. 5.0.1.
  20328.  
  20329. During the second stage of access control (request verification), the
  20330. server may, if the request involves tables, additionally consult the
  20331. `tables_priv' and `columns_priv' tables that provide finer control at
  20332. the table and column levels.  The columns in these tables are shown
  20333. here:
  20334.  
  20335. *Table Name*   *tables_priv*  *columns_priv*
  20336. *Scope         `Host'         `Host'
  20337. columns*                      
  20338.                `Db'           `Db'
  20339.                `User'         `User'
  20340.                `Table_name'   `Table_name'
  20341.                               `Column_name'
  20342. *Privilege     `Table_priv'   `Column_priv'
  20343. columns*                      
  20344.                `Column_priv'  
  20345. *Other         `Timestamp'    `Timestamp'
  20346. columns*                      
  20347.                `Grantor'      
  20348.  
  20349. The `Timestamp' and `Grantor' columns currently are unused and are
  20350. discussed no further here.
  20351.  
  20352. Each grant table contains scope columns and privilege columns:
  20353.  
  20354.    * Scope columns determine the scope of each entry (row) in the
  20355.      tables; that is, the context in which the entry applies.  For
  20356.      example, a `user' table entry with `Host' and `User' values of
  20357.      `'thomas.loc.gov'' and `'bob'' would be used for authenticating
  20358.      connections made to the server from the host `thomas.loc.gov' by a
  20359.      client that specifies a username of `bob'.  Similarly, a `db'
  20360.      table entry with `Host', `User', and `Db' column values of
  20361.      `'thomas.loc.gov'', `'bob'' and `'reports'' would be used when
  20362.      `bob' connects from the host `thomas.loc.gov' to access the
  20363.      `reports' database.  The `tables_priv' and `columns_priv' tables
  20364.      contain scope columns indicating tables or table/column
  20365.      combinations to which each entry applies.
  20366.  
  20367.    * Privilege columns indicate the privileges granted by a table
  20368.      entry; that is, what operations can be performed.  The server
  20369.      combines the information in the various grant tables to form a
  20370.      complete description of a user's privileges.  The rules used to do
  20371.      this are described in *Note Request access::.
  20372.  
  20373.  
  20374. Scope columns contain strings. They are declared as shown here; the
  20375. default value for each is the empty string:
  20376.  
  20377. *Column Name*  *Type*
  20378. `Host'         `CHAR(60)'
  20379. `User'         `CHAR(16)'
  20380. `Password'     `CHAR(16)'
  20381. `Db'           `CHAR(64)'
  20382. `Table_name'   `CHAR(60)'
  20383. `Column_name'  `CHAR(60)'
  20384.  
  20385. Before MySQL 3.23, the `Db' column is `CHAR(32)' in some tables and
  20386. `CHAR(60)' in others.
  20387.  
  20388. For access-checking purposes, comparisons of `Host' values are
  20389. case-insensitive.  `User', `Password', `Db', and `Table_name' values
  20390. are case sensitive.  `Column_name' values are case insensitive in MySQL
  20391. 3.22.12 or later.
  20392.  
  20393. In the `user', `db', and `host' tables, each privilege is listed in a
  20394. separate column that is declared as `ENUM('N','Y') DEFAULT 'N''. In
  20395. other words, each privilege can disabled or enabled, with the default
  20396. being disabled.
  20397.  
  20398. In the `tables_priv' and `columns_priv' tables, the privilege columns
  20399. are declared as `SET' columns. Values in these columns can contain any
  20400. combination of the privileges controlled by the table:
  20401.  
  20402. *Table      *Column     *Possible Set Elements*
  20403. Name*       Name*       
  20404. `tables_priv'`Table_priv'`'Select', 'Insert', 'Update',
  20405.                         'Delete', 'Create', 'Drop', 'Grant',
  20406.                         'References', 'Index', 'Alter''
  20407. `tables_priv'`Column_priv'`'Select', 'Insert', 'Update',
  20408.                         'References''
  20409. `columns_priv'`Column_priv'`'Select', 'Insert', 'Update',
  20410.                         'References''
  20411.  
  20412. Briefly, the server uses the grant tables as follows:
  20413.  
  20414.    * The `user' table scope columns determine whether to reject or allow
  20415.      incoming connections.  For allowed connections, any privileges
  20416.      granted in the `user' table indicate the user's global (superuser)
  20417.      privileges.  These privileges apply to _all_ databases on the
  20418.      server.
  20419.  
  20420.    * The `db' table scope columns determine which users can access which
  20421.      databases from which hosts.  The privilege columns determine which
  20422.      operations are allowed. A privilege granted at the database level
  20423.      applies to the database and to all its tables.
  20424.  
  20425.    * The `host' table is used in conjunction with the `db' table when
  20426.      you want a given `db' table entry to apply to several hosts.  For
  20427.      example, if you want a user to be able to use a database from
  20428.      several hosts in your network, leave the `Host' value empty in the
  20429.      user's `db' table entry, then populate the `host' table with an
  20430.      entry for each of those hosts.  This mechanism is described more
  20431.      detail in *Note Request access::.
  20432.  
  20433.      *Note*: The `host' table is not affected by the `GRANT' and
  20434.      `REVOKE' statements. Most MySQL installations need not use this
  20435.      table at all.
  20436.  
  20437.    * The `tables_priv' and `columns_priv' tables are similar to the
  20438.      `db' table, but are more fine-grained: They apply at the table and
  20439.      column levels rather than at the database level.  A privilege
  20440.      granted at the table level applies to the table and to all its
  20441.      columns.  A privilege granted at the column level applies only to
  20442.      a specific column.
  20443.  
  20444. Administrative privileges (such as `RELOAD' or `SHUTDOWN') are
  20445. specified only in the `user' table.  This is because administrative
  20446. operations are operations on the server itself and are not
  20447. database-specific, so there is no reason to list these privileges in the
  20448. other grant tables.  In fact, to determine whether you can perform an
  20449. administrative operation, the server need consult only the `user' table.
  20450.  
  20451. The `FILE' privilege also is specified only in the `user' table.  It is
  20452. not an administrative privilege as such, but your ability to read or
  20453. write files on the server host is independent of the database you are
  20454. accessing.
  20455.  
  20456. The `mysqld' server reads the contents of the grant tables into memory
  20457. when it starts. You can tell it to re-read the tables by issuing a
  20458. `FLUSH PRIVILEGES' statement or executing a `mysqladmin
  20459. flush-privileges' or `mysqladmin reload' command.  Changes to the grant
  20460. tables take effect as indicated in *Note Privilege changes::.
  20461.  
  20462. When you modify the contents of the grant tables, it is a good idea to
  20463. make sure that your changes set up privileges the way you want. One way
  20464. to check the privileges for a given account is to use the `SHOW GRANTS'
  20465. statement.  For example, to determine the privileges that are granted
  20466. to an account with `Host' and `User' values of `pc84.example.com' and
  20467. `bob', issue this statement:
  20468.  
  20469.      mysql> SHOW GRANTS FOR 'bob'@'pc84.example.com';
  20470.  
  20471. A useful diagnostic tool is the `mysqlaccess' script, which Yves
  20472. Carlier has provided for the MySQL distribution.  Invoke `mysqlaccess'
  20473. with the `--help' option to find out how it works.  Note that
  20474. `mysqlaccess' checks access using only the `user', `db', and `host'
  20475. tables.  It does not check table or column privileges specified in the
  20476. `tables_priv' or `columns_priv' tables.
  20477.  
  20478. For additional help in diagnosing privilege-related problems, see *Note
  20479. Access denied::.  For general advice on security issues, see *Note
  20480. Security::.
  20481.  
  20482. Privileges Provided by MySQL
  20483. ----------------------------
  20484.  
  20485. Information about account privileges is stored in the `user', `db',
  20486. `host', `tables_priv', and `columns_priv' tables in the `mysql'
  20487. database.  The MySQL server reads the contents of these tables into
  20488. memory when it starts and re-reads them under the circumstances
  20489. indicated in *Note Privilege changes::.  Access-control decisions are
  20490. based on the in-memory copies of the grant tables.
  20491.  
  20492. The names used in this manual to refer to the privileges provided by
  20493. MySQL are shown in the following table, along with the table column name
  20494. associated with each privilege in the grant tables and the context in
  20495. which the privilege applies. Further information about the meaning of
  20496. each privilege may be found at *Note `GRANT': GRANT.
  20497.  
  20498. *Privilege* *Column*       *Context*
  20499. `ALTER'     `Alter_priv'   tables
  20500. `DELETE'    `Delete_priv'  tables
  20501. `INDEX'     `Index_priv'   tables
  20502. `INSERT'    `Insert_priv'  tables
  20503. `SELECT'    `Select_priv'  tables
  20504. `UPDATE'    `Update_priv'  tables
  20505. `CREATE'    `Create_priv'  databases, tables, or
  20506.                            indexes
  20507. `DROP'      `Drop_priv'    databases or tables
  20508. `GRANT'     `Grant_priv'   databases or tables
  20509. `REFERENCES'`References_priv'databases or tables
  20510. `CREATE     `Create_tmp_table_priv'server administration
  20511. TEMPORARY                  
  20512. TABLES'                    
  20513. `EXECUTE'   `Execute_priv' server administration
  20514. `FILE'      `File_priv'    file access on server
  20515.                            host
  20516. `LOCK       `Lock_tables_priv'server administration
  20517. TABLES'                    
  20518. `PROCESS'   `Process_priv' server administration
  20519. `RELOAD'    `Reload_priv'  server administration
  20520. `REPLICATION`Repl_client_priv'server administration
  20521. CLIENT'                    
  20522. `REPLICATION`Repl_slave_priv'server administration
  20523. SLAVE'                     
  20524. `SHOW       `Show_db_priv' server administration
  20525. DATABASES'                 
  20526. `SHUTDOWN'  `Shutdown_priv'server administration
  20527. `SUPER'     `Super_priv'   server administration
  20528.  
  20529. The `CREATE TEMPORARY TABLES', `EXECUTE', `LOCK TABLES', `REPLICATION
  20530. CLIENT', `REPLICATION SLAVE', `SHOW DATABASES', and `SUPER' privileges
  20531. were added in MySQL 4.0.2.
  20532.  
  20533. The `EXECUTE' and `REFERENCES' privileges currently are unused.
  20534.  
  20535. The `SELECT', `INSERT', `UPDATE', and `DELETE' privileges allow you to
  20536. perform operations on rows in existing tables in a database.
  20537.  
  20538. `SELECT' statements require the `SELECT' privilege only if they
  20539. actually retrieve rows from a table.  Some `SELECT' statements do not
  20540. access tables and can be executed without permission for any database.
  20541. For example, you can use the `mysql' client as a simple calculator to
  20542. evaluate expressions that make no reference to tables:
  20543.  
  20544.      mysql> SELECT 1+1;
  20545.      mysql> SELECT PI()*2;
  20546.  
  20547. The `CREATE' and `DROP' privileges allow you to create new databases
  20548. and tables, or to drop (remove) existing databases and tables.  If you
  20549. grant the `DROP' privilege for the `mysql' database to a user, that
  20550. user can drop the database in which the MySQL access privileges are
  20551. stored!
  20552.  
  20553. The `INDEX' privilege allows you to create or drop (remove) indexes.
  20554. `INDEX' applies to existing tables.  If you have the `CREATE' privilege
  20555. for a table, you can include index definitions in the `CREATE TABLE'
  20556. statement.
  20557.  
  20558. The `ALTER' privilege allows you to use `ALTER TABLE' to change the
  20559. structure of or rename tables.
  20560.  
  20561. The `GRANT' privilege allows you to give to other users those
  20562. privileges that you yourself possess.
  20563.  
  20564. The `FILE' privilege gives you permission to read and write files on
  20565. the server host using the `LOAD DATA INFILE' and `SELECT ... INTO
  20566. OUTFILE' statements. A user who has the `FILE' privilege can read any
  20567. file on the server host that is either world-readable or readable by
  20568. the MySQL server. (This implies the user can read any file in any
  20569. database directory, because the server can access any of those files.)
  20570. The `FILE' privilege also allows the user to create new files in any
  20571. directory where the MySQL server has write access. Existing files
  20572. cannot be overwritten.
  20573.  
  20574. The remaining privileges are used for administrative operations. Many of
  20575. them can be performed by using the `mysqladmin' program or by issuing
  20576. SQL statements.  The following table shows which `mysqladmin' commands
  20577. each administrative privilege allows you to execute:
  20578.  
  20579. *Privilege* *Commands Permitted to Privilege Holders*
  20580. `RELOAD'    `flush-hosts', `flush-logs', `flush-privileges',
  20581.             `flush-status', `flush-tables', `flush-threads',
  20582.             `refresh', `reload'
  20583. `SHUTDOWN'  `shutdown'
  20584. `PROCESS'   `processlist'
  20585. `SUPER'     `kill'
  20586.  
  20587. The `reload' command tells the server to re-read the grant tables into
  20588. memory.  `flush-privileges' is a synonym for `reload'.  The `refresh'
  20589. command closes and reopens the log files and flushes all tables.  The
  20590. other `flush-XXX' commands perform functions similar to `refresh', but
  20591. are more specific and may be preferable in some instances.  For
  20592. example, if you want to flush just the log files, `flush-logs' is a
  20593. better choice than `refresh'.
  20594.  
  20595. The `shutdown' command shuts down the server. This command can be issued
  20596. only from `mysqladmin'. There is no corresponding SQL statement.
  20597.  
  20598. The `processlist' command displays information about the threads
  20599. executing within the server (that is, about the statements being
  20600. executed by clients associated with other accounts).  The `kill'
  20601. command terminates server threads.  You can always display or kill your
  20602. own threads, but you need the `PROCESS' privilege to display threads
  20603. initiated by other users and the `SUPER' privilege to kill them.  *Note
  20604. `KILL': KILL. Prior to MySQL 4.0.2 when `SUPER' was introduced, the
  20605. `PROCESS' privilege controls the ability to both see and terminate
  20606. threads for other clients.
  20607.  
  20608. The `CREATE TEMPORARY TABLES' privilege allows the use of the keyword
  20609. `TEMPORARY' in `CREATE TABLE' statements.
  20610.  
  20611. The `LOCK TABLES' privilege allows the use of explicit `LOCK TABLES'
  20612. statements to lock tables for which you have the `SELECT' privilege.
  20613. This includes the use of write locks, which prevents anyone else from
  20614. reading the locked table.
  20615.  
  20616. The `REPLICATION CLIENT' privilege allows the use of `SHOW MASTER
  20617. STATUS' and `SHOW SLAVE STATUS'.
  20618.  
  20619. The `REPLICATION SLAVE' privilege should be granted to accounts that are
  20620. used by slave servers when they connect to the current server as their
  20621. master.  Without this privilege, the slave cannot request updates that
  20622. have been made to databases on the master server.
  20623.  
  20624. The `SHOW DATABASES' privilege allows the account to see database names
  20625. by issuing the `SHOW DATABASE' statement. Accounts that do not have this
  20626. privilege see only databases for which they have some privileges, and
  20627. cannot use the statement at all if the server was started with the
  20628. `--skip-show-database' option.
  20629.  
  20630. It is a good idea in general to grant privileges to only those accounts
  20631. that need them, but you should exercise particular caution in granting
  20632. administrative privileges:
  20633.  
  20634.    * The `GRANT' privilege allows users to give their privileges to
  20635.      other users.  Two users with different privileges and with the
  20636.      `GRANT' privilege are able to combine privileges.
  20637.  
  20638.    * The `ALTER' privilege may be used to subvert the privilege system
  20639.      by renaming tables.
  20640.  
  20641.    * The `FILE' privilege can be abused to read into a database table
  20642.      any files that the MySQL server can read on the server host. This
  20643.      includes all world-readable files and files in the server's data
  20644.      directory. The table can then be accessed using `SELECT' to
  20645.      transfer its contents to the client host.
  20646.  
  20647.    * The `SHUTDOWN' privilege can be abused to deny service to other
  20648.      users entirely by terminating the server.
  20649.  
  20650.    * The `PROCESS' privilege can be used to view the plain text of
  20651.      currently executing queries, including queries that set or change
  20652.      passwords.
  20653.  
  20654.    * The `SUPER' privilege can be used to terminate other clients or
  20655.      change how the server operates.
  20656.  
  20657.    * Privileges granted for the `mysql' database itself can be used to
  20658.      change passwords and other access privilege information.
  20659.      Passwords are stored encrypted, so a malicious user cannot simply
  20660.      read them to know the plain text password.  However, a user with
  20661.      write access to the `user' table `Password' column can change an
  20662.      account's password, and then connect to the MySQL server using
  20663.      that account.
  20664.  
  20665.  
  20666. There are some things that you cannot do with the MySQL privilege
  20667. system:
  20668.  
  20669.    * You cannot explicitly specify that a given user should be denied
  20670.      access.  That is, you cannot explicitly match a user and then
  20671.      refuse the connection.
  20672.  
  20673.    * You cannot specify that a user has privileges to create or drop
  20674.      tables in a database but not to create or drop the database itself.
  20675.  
  20676. Connecting to the MySQL Server
  20677. ------------------------------
  20678.  
  20679. MySQL client programs generally expect you to specify connection
  20680. parameters when you want to access a MySQL server:
  20681.  
  20682.    * The name of the host where the MySQL server is running
  20683.  
  20684.    * Your username
  20685.  
  20686.    * Your password
  20687.  
  20688. For example, the `mysql' client can be started as follows from a
  20689. command-line prompt (indicated here by `shell>'):
  20690.  
  20691.      shell> mysql -h HOST_NAME -u USER_NAME -pYOUR_PASS
  20692.  
  20693. Alternate forms of the `-h', `-u', and `-p' options are
  20694. `--host=HOST_NAME', `--user=USER_NAME', and `--password=YOUR_PASS'.
  20695. Note that there is _no space_ between `-p' or `--password=' and the
  20696. password following it.
  20697.  
  20698. If you use a `-p' or `--password' option but do not specify the
  20699. password value, the client program will prompt you to enter the
  20700. password.  The password is not displayed as you enter it.  This is more
  20701. secure than giving the password on the command line.  Any user on your
  20702. system may be able to see a password specified on the command line by
  20703. executing a command such as `ps auxww'.  *Note Password security::.
  20704.  
  20705. MySQL client programs use default values for any connection parameter
  20706. option that you do not specify:
  20707.  
  20708.    * The default hostname is `localhost'.
  20709.  
  20710.    * The default username is `ODBC' on Windows and your Unix login name
  20711.      on Unix.
  20712.  
  20713.    * No password is supplied if `-p' is missing.
  20714.  
  20715. Thus, for a Unix user with a login name of `joe', all of the following
  20716. commands are equivalent:
  20717.  
  20718.      shell> mysql -h localhost -u joe
  20719.      shell> mysql -h localhost
  20720.      shell> mysql -u joe
  20721.      shell> mysql
  20722.  
  20723. Other MySQL clients behave similarly.
  20724.  
  20725. You can specify different default values to be used when you make a
  20726. connection so that you need not enter them on the command line each
  20727. time you invoke a client program.  This can be done in a couple of ways:
  20728.  
  20729.    * You can specify connection parameters in the `[client]' section of
  20730.      an option file.  The relevant section of the file might look like
  20731.      this:
  20732.  
  20733.           [client]
  20734.           host=HOST_NAME
  20735.           user=USER_NAME
  20736.           password=YOUR_PASS
  20737.  
  20738.      Option files are discussed further in *Note Option files::.
  20739.  
  20740.    * You can specify some connection parameters using environment
  20741.      variables.  The host can be specified for `mysql' using
  20742.      `MYSQL_HOST'.  The MySQL username can be specified using `USER'
  20743.      (this is for Windows and NetWare only).  The password can be
  20744.      specified using `MYSQL_PWD', although this is insecure; see *Note
  20745.      Password security::.  For a list of variables, see *Note
  20746.      Environment variables::.
  20747.  
  20748. Access Control, Stage 1: Connection Verification
  20749. ------------------------------------------------
  20750.  
  20751. When you attempt to connect to a MySQL server, the server accepts or
  20752. rejects the connection based on your identity and whether you can
  20753. verify your identity by supplying the correct password.  If not, the
  20754. server denies access to you completely.  Otherwise, the server accepts
  20755. the connection, then enters Stage 2 and waits for requests.
  20756.  
  20757. Your identity is based on two pieces of information:
  20758.  
  20759.    * The client host from which you connect
  20760.  
  20761.    * Your MySQL username
  20762.  
  20763. Identity checking is performed using the three `user' table scope
  20764. columns (`Host', `User', and `Password').  The server accepts the
  20765. connection only if the `Host' and `User' columns in some `user' table
  20766. record match the client hostname and username, and the client supplies
  20767. the password specified in that record.
  20768.  
  20769. `Host' values in the `user' table may be specified as follows:
  20770.  
  20771.    * A `Host' value may be a hostname or an IP number, or `'localhost''
  20772.      to indicate the local host.
  20773.  
  20774.    * You can use the wildcard characters `%' and `_' in `Host' column
  20775.      values.  These have the same meaning as for pattern-matching
  20776.      operations performed with the `LIKE' operator.  For example, a
  20777.      `Host' value of `'%'' matches any hostname, whereas a value of
  20778.      `'%.mysql.com'' matches any host in the `mysql.com' domain.
  20779.  
  20780.    * As of MySQL 3.23, for `Host' values specified as IP numbers, you
  20781.      can specify a netmask indicating how many address bits to use for
  20782.      the network number. For example:
  20783.  
  20784.           mysql> GRANT ALL PRIVILEGES ON db.*
  20785.               -> TO david@'192.58.197.0/255.255.255.0';
  20786.  
  20787.      This allows `david' to connect from any client host having an IP
  20788.      number `client_ip' for which the following condition is true:
  20789.  
  20790.           client_ip & netmask = host_ip
  20791.  
  20792.      That is, for the `GRANT' statement just shown:
  20793.  
  20794.           client_ip & 255.255.255.0 = 192.58.197.0
  20795.  
  20796.      IP numbers that satisfy this condition and can connect to the
  20797.      MySQL server are those that lie in the range from `192.58.197.0' to
  20798.      `192.58.197.255'.
  20799.  
  20800.    * A blank `Host' value in a `db' table record means that its
  20801.      privileges should be combined with those in the entry in the `host'
  20802.      table that matches the client hostname.  The privileges are
  20803.      combined using an AND (intersection) operation, not OR (union).
  20804.      You can find more information about the `host' table in *Note
  20805.      Request access::.
  20806.  
  20807.      A blank `Host' value in the other grant tables is the same as
  20808.      `'%''.
  20809.  
  20810.  
  20811. Because you can use IP wildcard values in the `Host' column (for
  20812. example, `'144.155.166.%'' to match every host on a subnet), someone
  20813. could try to exploit this capability by naming a host
  20814. `144.155.166.somewhere.com'.  To foil such attempts, MySQL disallows
  20815. matching on hostnames that start with digits and a dot. Thus, if you
  20816. have a host named something like `1.2.foo.com', its name will never
  20817. match the `Host' column of the grant tables.  An IP wildcard value can
  20818. match only IP numbers, not hostnames.
  20819.  
  20820. In the `User' column, wildcard characters are not allowed, but you can
  20821. specify a blank value, which matches any name.  If the `user' table
  20822. entry that matches an incoming connection has a blank username, the
  20823. user is considered to be an anonymous user with no name, not a user
  20824. with the name that the client actually specified.  This means that a
  20825. blank username is used for all further access checking for the duration
  20826. of the connection (that is, during Stage 2).
  20827.  
  20828. The `Password' column can be blank.  This is not a wildcard and does
  20829. not mean that any password matches. It means that the user must connect
  20830. without specifying a password.
  20831.  
  20832. Non-blank `Password' values in the `user' table represent encrypted
  20833. passwords.  MySQL does not store passwords in plaintext form for anyone
  20834. to see.  Rather, the password supplied by a user who is attempting to
  20835. connect is encrypted (using the `PASSWORD()' function). The encrypted
  20836. password then is used during the connection process when checking
  20837. whether the password is correct. (This is done without the encrypted
  20838. password ever traveling over the connection.)  From MySQL's point of
  20839. view, the encrypted password is the REAL password, so you should not
  20840. give anyone access to it!  In particular, don't give non-administrative
  20841. users read access to the tables in the `mysql' database!
  20842.  
  20843. From version 4.1 on, MySQL employs a stronger authentication method
  20844. that has better password protection during the connection process than
  20845. in earlier versions. It is secure even if TCP/IP packets are sniffed or
  20846. the `mysql' database is captured.  Password encryption is discussed
  20847. further in *Note Password hashing::.
  20848.  
  20849. The following examples show how various combinations of `Host' and
  20850. `User' values in the `user' table apply to incoming connections:
  20851.  
  20852. `Host' *Value*            `User'      *Connections Matched by Entry*
  20853.                           *Value*     
  20854. `'thomas.loc.gov''        `'fred''    `fred', connecting from
  20855.                                       `thomas.loc.gov'
  20856. `'thomas.loc.gov''        `'''        Any user, connecting from
  20857.                                       `thomas.loc.gov'
  20858. `'%''                     `'fred''    `fred', connecting from any host
  20859. `'%''                     `'''        Any user, connecting from any host
  20860. `'%.loc.gov''             `'fred''    `fred', connecting from any host in
  20861.                                       the `loc.gov' domain
  20862. `'x.y.%''                 `'fred''    `fred', connecting from `x.y.net',
  20863.                                       `x.y.com', `x.y.edu', and so on.
  20864.                                       (this is probably not useful)
  20865. `'144.155.166.177''       `'fred''    `fred', connecting from the host
  20866.                                       with IP address `144.155.166.177'
  20867. `'144.155.166.%''         `'fred''    `fred', connecting from any host in
  20868.                                       the `144.155.166' class C subnet
  20869. `'144.155.166.0/255.255.255.0''`'fred''    Same as previous example
  20870.  
  20871. It is possible for the client hostname and username of an incoming
  20872. connection to match more than one entry in the `user' table.  The
  20873. preceding set of examples demonstrates this: Several of the entries
  20874. shown match a connection from `thomas.loc.gov' by `fred'.
  20875.  
  20876. When multiple matches are possible, the server must determine which of
  20877. them to use.  It resolves this issue as follows:
  20878.  
  20879.    * Whenever the server reads the `user' table into memory, it sorts
  20880.      the entries.
  20881.  
  20882.    * When a client attempts to connect, the server looks through the
  20883.      entries in sorted order.
  20884.  
  20885.    * The server uses the first entry that matches the client hostname
  20886.      and username.
  20887.  
  20888. To see how this works, suppose that the `user' table looks like this:
  20889.  
  20890.      +-----------+----------+-
  20891.      | Host      | User     | ...
  20892.      +-----------+----------+-
  20893.      | %         | root     | ...
  20894.      | %         | jeffrey  | ...
  20895.      | localhost | root     | ...
  20896.      | localhost |          | ...
  20897.      +-----------+----------+-
  20898.  
  20899. When the server reads in the table, it orders the entries with the
  20900. most-specific `Host' values first.  Literal hostnames and IP numbers
  20901. are the most specific. The pattern `'%'' means "any host" and is least
  20902. specific.  Entries with the same `Host' value are ordered with the
  20903. most-specific `User' values first (a blank `User' value means "any
  20904. user" and is least specific). For the `user' table just shown, the
  20905. result after sorting looks like this:
  20906.  
  20907.      +-----------+----------+-
  20908.      | Host      | User     | ...
  20909.      +-----------+----------+-
  20910.      | localhost | root     | ...
  20911.      | localhost |          | ...
  20912.      | %         | jeffrey  | ...
  20913.      | %         | root     | ...
  20914.      +-----------+----------+-
  20915.  
  20916. When a client attempts to connect, the server looks through the sorted
  20917. entries and uses the first match found.  For a connection from
  20918. `localhost' by `jeffrey', two of the entries in the table match: the
  20919. one with `Host' and `User' values of `'localhost'' and `''', and the
  20920. one with values of `'%'' and `'jeffrey''.  The `'localhost'' entry
  20921. appears first in sorted order, so that is the one the server uses.
  20922.  
  20923. Here is another example.  Suppose that the `user' table looks like this:
  20924.  
  20925.      +----------------+----------+-
  20926.      | Host           | User     | ...
  20927.      +----------------+----------+-
  20928.      | %              | jeffrey  | ...
  20929.      | thomas.loc.gov |          | ...
  20930.      +----------------+----------+-
  20931.  
  20932. The sorted table looks like this:
  20933.  
  20934.      +----------------+----------+-
  20935.      | Host           | User     | ...
  20936.      +----------------+----------+-
  20937.      | thomas.loc.gov |          | ...
  20938.      | %              | jeffrey  | ...
  20939.      +----------------+----------+-
  20940.  
  20941. A connection by `jeffrey' from `thomas.loc.gov' is matched by the first
  20942. entry, whereas a connection by `jeffrey' from `whitehouse.gov' is
  20943. matched by the second.
  20944.  
  20945. It is a common misconception to think that, for a given username, all
  20946. entries that explicitly name that user will be used first when the
  20947. server attempts to find a match for the connection.  This is simply not
  20948. true.  The previous example illustrates this, where a connection from
  20949. `thomas.loc.gov' by `jeffrey' is first matched not by the entry
  20950. containing `'jeffrey'' as the `User' column value, but by the entry
  20951. with no username!  As a result, `jeffrey' will be authenticated as an
  20952. anonymous user, even though he specified a username when connecting.
  20953.  
  20954. If you are able to connect to the server, but your privileges are not
  20955. what you expect, you probably are being authenticated as some other
  20956. account.  To find out what account the server used to authenticate you,
  20957. use the `CURRENT_USER()' function. It returns a value in
  20958. `USER_NAME@HOST_NAME' format that indicates the `User' and `Host'
  20959. values from the matching `user' table record.  Suppose that `jeffrey'
  20960. connects and issues the following query:
  20961.  
  20962.      mysql> SELECT CURRENT_USER();
  20963.      +----------------+
  20964.      | CURRENT_USER() |
  20965.      +----------------+
  20966.      | @localhost     |
  20967.      +----------------+
  20968.  
  20969. The result shown here indicates that the matching `user' table entry
  20970. had a blank `User' column value.  In other words, the server is
  20971. treating `jeffrey' as an anonymous user.
  20972.  
  20973. The `CURRENT_USER()' function is available as of MySQL 4.0.6.  *Note
  20974. Information functions::.  Another thing you can do to diagnose
  20975. authentication problems is to print out the `user' table and sort it by
  20976. hand to see where the first match is being made.
  20977.  
  20978. Access Control, Stage 2: Request Verification
  20979. ---------------------------------------------
  20980.  
  20981. Once you establish a connection, the server enters Stage 2 of access
  20982. control.  For each request that comes in on the connection, the server
  20983. determines what operation you want to perform, then checks whether you
  20984. have sufficient privileges to do so.  This is where the privilege
  20985. columns in the grant tables come into play.  These privileges can come
  20986. from any of the `user', `db', `host', `tables_priv', or `columns_priv'
  20987. tables.  (You may find it helpful to refer to *Note Privileges::, which
  20988. lists the columns present in each of the grant tables.)
  20989.  
  20990. The `user' table grants privileges that are assigned to you on a global
  20991. basis and that apply no matter what the current database is.  For
  20992. example, if the `user' table grants you the `DELETE' privilege, you can
  20993. delete rows from any table in any database on the server host!  In
  20994. other words, `user' table privileges are superuser privileges.  It is
  20995. wise to grant privileges in the `user' table only to superusers such as
  20996. database administrators.  For other users, you should leave the
  20997. privileges in the `user' table set to `'N'' and grant privileges at more
  20998. specific levels only. You can grant privileges for particular databases,
  20999. tables, or columns.
  21000.  
  21001. The `db' and `host' tables grant database-specific privileges.  Values
  21002. in the scope columns of these tables can take the following forms:
  21003.  
  21004.    * The wildcard characters `%' and `_' can be used in the `Host' and
  21005.      `Db' columns of either table.  These have the same meaning as for
  21006.      pattern-matching operations performed with the `LIKE' operator.
  21007.      If you want to use either character literally when granting
  21008.      privileges, you must escape it with a backslash.  For example, to
  21009.      include `_' character as part of a database name, specify it as
  21010.      `\_' in the `GRANT' statement.
  21011.  
  21012.    * A `'%'' `Host' value in the `db' table means "any host." A blank
  21013.      `Host' value in the `db' table means "consult the `host' table for
  21014.      further information" (a process that is described later in this
  21015.      section).
  21016.  
  21017.    * A `'%'' or blank `Host' value in the `host' table means "any host."
  21018.  
  21019.    * A `'%'' or blank `Db' value in either table means "any database."
  21020.  
  21021.    * A blank `User' value in either table matches the anonymous user.
  21022.  
  21023. The server reads in and sorts the `db' and `host' tables at the same
  21024. time that it reads the `user' table.  The server sorts the `db' table
  21025. based on the `Host', `Db', and `User' scope columns, and sorts the
  21026. `host' table based on the `Host' and `Db' scope columns.  As with the
  21027. `user' table, sorting puts the most-specific values first and
  21028. least-specific values last, and when the server looks for matching
  21029. entries, it uses the first match that it finds.
  21030.  
  21031. The `tables_priv' and `columns_priv' tables grant table-specific and
  21032. column-specific privileges.  Values in the scope columns of these
  21033. tables can take the following form:
  21034.  
  21035.    * The wildcard characters `%' and `_' can be used in the `Host'
  21036.      column of either table.  These have the same meaning as for
  21037.      pattern-matching operations performed with the `LIKE' operator.
  21038.  
  21039.    * A `'%'' or blank `Host' value in either table means "any host."
  21040.  
  21041.    * The `Db', `Table_name', and `Column_name' columns cannot contain
  21042.      wildcards or be blank in either table.
  21043.  
  21044. The server sorts the `tables_priv' and `columns_priv' tables based on
  21045. the `Host', `Db', and `User' columns.  This is similar to `db' table
  21046. sorting, but simpler because only the `Host' column can contain
  21047. wildcards.
  21048.  
  21049. The request verification process is described here.  (If you are
  21050. familiar with the access-checking source code, you will notice that the
  21051. description here differs slightly from the algorithm used in the code.
  21052. The description is equivalent to what the code actually does; it
  21053. differs only to make the explanation simpler.)
  21054.  
  21055. For requests that require administrative privileges such as `SHUTDOWN'
  21056. or `RELOAD', the server checks only the `user' table entry because that
  21057. is the only table that specifies administrative privileges.  Access is
  21058. granted if the entry allows the requested operation and denied
  21059. otherwise.  For example, if you want to execute `mysqladmin shutdown'
  21060. but your `user' table entry doesn't grant the `SHUTDOWN' privilege to
  21061. you, the server denies access without even checking the `db' or `host'
  21062. tables.  (They contain no `Shutdown_priv' column, so there is no need
  21063. to do so.)
  21064.  
  21065. For database-related requests (`INSERT', `UPDATE', and so on), the
  21066. server first checks the user's global (superuser) privileges by looking
  21067. in the `user' table entry.  If the entry allows the requested operation,
  21068. access is granted.  If the global privileges in the `user' table are
  21069. insufficient, the server determines the user's database-specific
  21070. privileges by checking the `db' and `host' tables:
  21071.  
  21072.   1. The server looks in the `db' table for a match on the `Host',
  21073.      `Db', and `User' columns.  The `Host' and `User' columns are
  21074.      matched to the connecting user's hostname and MySQL username.  The
  21075.      `Db' column is matched to the database that the user wants to
  21076.      access.  If there is no entry for the `Host' and `User', access is
  21077.      denied.
  21078.  
  21079.   2. If there is a matching `db' table entry and its `Host' column is
  21080.      not blank, that entry defines the user's database-specific
  21081.      privileges.
  21082.  
  21083.   3. If the matching `db' table entry's `Host' column is blank, it
  21084.      signifies that the `host' table enumerates which hosts should be
  21085.      allowed access to the database.  In this case, a further lookup is
  21086.      done in the `host' table to find a match on the `Host' and `Db'
  21087.      columns.  If no `host' table entry matches, access is denied.  If
  21088.      there is a match, the user's database-specific privileges are
  21089.      computed as the intersection (_not_ the union!) of the privileges
  21090.      in the `db' and `host' table entries; that is, the privileges that
  21091.      are `'Y'' in both entries.  (This way you can grant general
  21092.      privileges in the `db' table entry and then selectively restrict
  21093.      them on a host-by-host basis using the `host' table entries.)
  21094.  
  21095. After determining the database-specific privileges granted by the `db'
  21096. and `host' table entries, the server adds them to the global privileges
  21097. granted by the `user' table.  If the result allows the requested
  21098. operation, access is granted.  Otherwise, the server successively
  21099. checks the user's table and column privileges in the `tables_priv' and
  21100. `columns_priv' tables, adds those to the user's privileges, and allows
  21101. or denies access based on the result.
  21102.  
  21103. Expressed in boolean terms, the preceding description of how a user's
  21104. privileges are calculated may be summarized like this:
  21105.  
  21106.      global privileges
  21107.      OR (database privileges AND host privileges)
  21108.      OR table privileges
  21109.      OR column privileges
  21110.  
  21111. It may not be apparent why, if the global `user' entry privileges are
  21112. initially found to be insufficient for the requested operation, the
  21113. server adds those privileges to the database, table, and column
  21114. privileges later. The reason is that a request might require more than
  21115. one type of privilege.  For example, if you execute an `INSERT INTO ...
  21116. SELECT' statement, you need both the `INSERT' and the `SELECT'
  21117. privileges.  Your privileges might be such that the `user' table entry
  21118. grants one privilege and the `db' table entry grants the other.  In
  21119. this case, you have the necessary privileges to perform the request,
  21120. but the server cannot tell that from either table by itself; the
  21121. privileges granted by the entries in both tables must be combined.
  21122.  
  21123. The `host' table is not affected by the `GRANT' or `REVOKE' statements,
  21124. so it is unused in most MySQL installations. If you modify it directly,
  21125. you can use it for some specialized purposes, such as to to maintain a
  21126. list of secure servers.  For example, at TcX, the `host' table contains
  21127. a list of all machines on the local network. These are granted all
  21128. privileges.
  21129.  
  21130. You can also use the `host' table to indicate hosts that are _not_
  21131. secure.  Suppose that you have a machine `public.your.domain' that is
  21132. located in a public area that you do not consider secure.  You can
  21133. allow access to all hosts on your network except that machine by using
  21134. `host' table entries like this:
  21135.  
  21136.      +--------------------+----+-
  21137.      | Host               | Db | ...
  21138.      +--------------------+----+-
  21139.      | public.your.domain | %  | ... (all privileges set to 'N')
  21140.      | %.your.domain      | %  | ... (all privileges set to 'Y')
  21141.      +--------------------+----+-
  21142.  
  21143. Naturally, you should always test your entries in the grant tables (for
  21144. example, by using `SHOW GRANTS' or `mysqlaccess') to make sure that
  21145. your access privileges are actually set up the way you think they are.
  21146.  
  21147. When Privilege Changes Take Effect
  21148. ----------------------------------
  21149.  
  21150. When `mysqld' starts, all grant table contents are read into memory and
  21151. become effective for access control at that point.
  21152.  
  21153. When the server reloads the grant tables, privileges for existing
  21154. client connections are affected as follows:
  21155.  
  21156.    * Table and column privilege changes take effect with the client's
  21157.      next request.
  21158.  
  21159.    * Database privilege changes take effect at the next `USE DB_NAME'
  21160.      statement.
  21161.  
  21162.    * Changes to global privileges and passwords take effect the next
  21163.      time the client connects.
  21164.  
  21165. If you modify the grant tables using `GRANT', `REVOKE', or `SET
  21166. PASSWORD', the server notices these changes and reloads the grant
  21167. tables into memory again immediately.
  21168.  
  21169. If you modify the grant tables directly using statements such as
  21170. `INSERT', `UPDATE', or `DELETE', your changes have no effect on
  21171. privilege checking until you either restart the server or tell it to
  21172. reload the tables.  To reload the grant tables manually, issue a `FLUSH
  21173. PRIVILEGES' statement or execute a `mysqladmin flush-privileges' or
  21174. `mysqladmin reload' command.
  21175.  
  21176. If you change the grant tables directly but forget to reload them, your
  21177. changes will have _no effect_ until you restart the server.  This may
  21178. leave you wondering why your changes don't seem to make any difference!
  21179.  
  21180. Causes of `Access denied' Errors
  21181. --------------------------------
  21182.  
  21183. If you encounter problems when you try to connect to the MySQL server,
  21184. the following items describe some courses of action you can take to
  21185. correct the problem.
  21186.  
  21187.    * Make sure that the server is running. If it is not running, you
  21188.      cannot connect to it.  For example, if you attempt to connect to
  21189.      the server and see a message such as one of those following, one
  21190.      cause might be that the server is not running:
  21191.  
  21192.           shell> mysql
  21193.           ERROR 2003: Can't connect to MySQL server on 'HOST_NAME' (111)
  21194.           shell> mysql
  21195.           ERROR 2002: Can't connect to local MySQL server through socket
  21196.           '/tmp/mysql.sock' (111)
  21197.  
  21198.      It might also be that the server is running, but you are trying to
  21199.      connect using a TCP/IP port, named pipe, or Unix socket file
  21200.      different from those on which the server is listening. To correct
  21201.      this when you invoke a client program, specify a `--port' option
  21202.      to indicate the proper port, or a `--socket' option to indicate
  21203.      the proper named pipe or Unix socket file.  To find out what port
  21204.      is used, and where the socket is, you can do:
  21205.  
  21206.           shell> netstat -l | grep mysql
  21207.  
  21208.    * The grant tables must be properly set up so that the server can
  21209.      use them for access control.  For some distribution types (such as
  21210.      binary distributions on Windows on RPM distributions on Linux),
  21211.      the installation process initializes the `mysql' database
  21212.      containing the grant tables.  For distributions that do not do
  21213.      this, you should initialize the grant tables manually by running
  21214.      the `mysql_install_db' script.  For details, see *Note Unix
  21215.      post-installation::.
  21216.  
  21217.      One way to determine whether you need to initialize the grant
  21218.      tables is to look for a `mysql' directory under the data
  21219.      directory. (The data directory normally is named `data' or `var'
  21220.      and is located under your MySQL installation directory.)  Make
  21221.      sure that you have a file named `user.MYD' in the `mysql' database
  21222.      directory.  If you do not, execute the `mysql_install_db' script.
  21223.      After running this script and starting the server, test the
  21224.      initial privileges by executing this command:
  21225.  
  21226.           shell> mysql -u root test
  21227.  
  21228.      The server should let you connect without error.
  21229.  
  21230.    * After a fresh installation, you should connect to the server and
  21231.      set up your users and their access permissions:
  21232.  
  21233.           shell> mysql -u root mysql
  21234.  
  21235.      The server should let you connect because the MySQL `root' user
  21236.      has no password initially.  That is also a security risk, so
  21237.      setting the password for the `root' accounts is something you
  21238.      should do while you're setting up your other MySQL users.  For
  21239.      instructions on setting the initial passwords, see *Note Default
  21240.      privileges::.
  21241.  
  21242.    * If you have updated an existing MySQL installation to a newer
  21243.      version, did you run the `mysql_fix_privilege_tables' script?  If
  21244.      not, do so. The structure of the grant tables changes occasionally
  21245.      when new capabilities are added, so after an upgrade you should
  21246.      always make sure that your tables have the current structure. For
  21247.      instructions, see *Note Upgrading-grant-tables::.
  21248.  
  21249.    * If a client program receives the following error message when it
  21250.      tries to connect, it means that the server expects passwords in a
  21251.      newer format than the client is capable of generating:
  21252.  
  21253.           shell> mysql
  21254.           Client does not support authentication protocol requested
  21255.           by server; consider upgrading MySQL client
  21256.  
  21257.      For information on how to deal with this, see *Note Password
  21258.      hashing:: and *Note Old client::.
  21259.  
  21260.    * If you try to connect as `root' and get the following error, it
  21261.      means that you don't have an entry in the `user' table with a
  21262.      `User' column value of `'root'' and that `mysqld' cannot resolve
  21263.      the hostname for your client:
  21264.  
  21265.           Access denied for user ''@'unknown' to database mysql
  21266.  
  21267.      In this case, you must restart the server with the
  21268.      `--skip-grant-tables' option and edit your `/etc/hosts' or
  21269.      `\windows\hosts' file to add an entry for your host.
  21270.  
  21271.    * Remember that client programs will use connection parameters
  21272.      specified in option files or environment variables.  If a client
  21273.      program seems to be sending incorrect default connection
  21274.      parameters when you don't specify them on the command line, check
  21275.      your environment and any applicable option files. For example, if
  21276.      you get `Access denied' when you run a client without any options,
  21277.      make sure that you haven't specified an old password in any of
  21278.      your option files!
  21279.  
  21280.      You can suppress the use of option files by a client program by
  21281.      invoking it with the `--no-defaults' option. For example:
  21282.  
  21283.           shell> mysqladmin --no-defaults -u root version
  21284.  
  21285.      The option files that clients use are listed in *Note Option
  21286.      files::.  Environment variables are listed in *Note Environment
  21287.      variables::.
  21288.  
  21289.    * If you get the following error, it means that you are using an
  21290.      incorrect `root' password:
  21291.  
  21292.           shell> mysqladmin -u root -pXXXX ver
  21293.           Access denied for user 'root'@'localhost' (using password: YES)
  21294.  
  21295.      If the preceding error occurs even when you haven't specified a
  21296.      password, it means that you have an incorrect password listed in
  21297.      some option file. Try the `--no-defaults' option as described in
  21298.      the previous item.
  21299.  
  21300.      For information on changing passwords, see *Note Passwords::.
  21301.  
  21302.      If you have lost or forgotten the `root' password, you can restart
  21303.      `mysqld' with `--skip-grant-tables' to change the password.  *Note
  21304.      Resetting permissions::.
  21305.  
  21306.    * If you change a password by using `SET PASSWORD', `INSERT', or
  21307.      `UPDATE', you must encrypt the password using the `PASSWORD()'
  21308.      function.  If you do not use `PASSWORD()' for these statements,
  21309.      the password will not work. For example, the following statement
  21310.      sets a password, but fails to encrypt it, so the user will not be
  21311.      able to connect afterward:
  21312.  
  21313.           mysql> SET PASSWORD FOR 'abe'@'HOST_NAME' = 'eagle';
  21314.  
  21315.      Instead, set the password like this:
  21316.  
  21317.           mysql> SET PASSWORD FOR 'abe'@'HOST_NAME' = PASSWORD('eagle');
  21318.  
  21319.      The `PASSWORD()' function is unnecessary when you specify a
  21320.      password using the `GRANT' statement or the `mysqladmin password'
  21321.      command, both of which automatically use `PASSWORD()' to encrypt
  21322.      the password.  *Note Passwords::.
  21323.  
  21324.    * `localhost' is a synonym for your local hostname, and is also the
  21325.      default host to which clients try to connect if you specify no host
  21326.      explicitly.  However, connections to `localhost' on Unix systems
  21327.      do not work if you are using a MySQL version older than 3.23.27
  21328.      that uses MIT-pthreads: `localhost' connections are made using
  21329.      Unix socket files, which were not supported by MIT-pthreads at
  21330.      that time.
  21331.  
  21332.      To avoid this problem on such systems, you can use a
  21333.      `--host=127.0.0.1' option to name the server host explicitly.
  21334.      This will make a TCP/IP connection to the local `mysqld' server.
  21335.      You can also use TCP/IP by specifying a `--host' option that uses
  21336.      the actual hostname of the local host.  In this case, the hostname
  21337.      must be specified in a `user' table entry on the server host, even
  21338.      though you are running the client program on the same host as the
  21339.      server.
  21340.  
  21341.    * If you get an `Access denied' error when trying to connect to the
  21342.      database with `mysql -u user_name', you may have a problem with
  21343.      the `user' table. Check this by executing `mysql -u root mysql'
  21344.      and issuing this SQL statement:
  21345.  
  21346.           mysql> SELECT * FROM user;
  21347.  
  21348.      The result should include an entry with the `Host' and `User'
  21349.      columns matching your computer's hostname and your MySQL username.
  21350.  
  21351.    * The `Access denied' error message will tell you who you are trying
  21352.      to log in as, the client host from which you are trying to
  21353.      connect, and whether or not you were using a password. Normally,
  21354.      you should have one entry in the `user' table that exactly matches
  21355.      the hostname and username that were given in the error message.
  21356.      For example, if you get an error message that contains `using
  21357.      password: NO', it means that you tried to log in without an
  21358.      password.
  21359.  
  21360.    * If the following error occurs when you try to connect from a host
  21361.      other than the one on which the MySQL server is running, it means
  21362.      that there is no row in the `user' table with a `Host' value that
  21363.      matches the client host:
  21364.  
  21365.           Host ... is not allowed to connect to this MySQL server
  21366.  
  21367.      You can fix this by setting up an account for the combination of
  21368.      client hostname and username that you are using when trying to
  21369.      connect.
  21370.  
  21371.      If you don't know the IP number or hostname of the machine from
  21372.      which you are connecting, you should put an entry with `'%'' as
  21373.      the `Host' column value in the `user' table and restart `mysqld'
  21374.      with the `--log' option on the server machine.  After trying to
  21375.      connect from the client machine, the information in the MySQL log
  21376.      will indicate how you really did connect.  (Then change the `'%''
  21377.      in the `user' table entry to the actual hostname that shows up in
  21378.      the log.  Otherwise, you'll have a system that is insecure because
  21379.      it allows connections from any host for the given username.)
  21380.  
  21381.      On Linux, another reason that this error might occur is that you
  21382.      are using a binary MySQL version that is compiled with a different
  21383.      version of the `glibc' library than the one you are using.  In
  21384.      this case, you should either upgrade your operating system or
  21385.      `glibc', or download a source distribution of MySQL version and
  21386.      compile it yourself.  A source RPM is normally trivial to compile
  21387.      and install, so this isn't a big problem.
  21388.  
  21389.    * If you specify a hostname when trying to connect, but get an error
  21390.      message where the hostname is not shown or is an IP number, it
  21391.      means that the MySQL server got an error when trying to resolve the
  21392.      IP number of the client host to a name:
  21393.  
  21394.           shell> mysqladmin -u root -pXXXX -h SOME-HOSTNAME ver
  21395.           Access denied for user 'root'@'' (using password: YES)
  21396.  
  21397.      This indicates a DNS problem.  To fix it, execute `mysqladmin
  21398.      flush-hosts' to reset the internal DNS hostname cache. *Note DNS::.
  21399.  
  21400.      Some permanent solutions are:
  21401.  
  21402.         - Try to find out what is wrong with your DNS server and fix it.
  21403.  
  21404.         - Specify IP numbers rather than hostnames in the MySQL grant
  21405.           tables.
  21406.  
  21407.         - Put an entry for the client machine name in `/etc/hosts'.
  21408.  
  21409.         - Start `mysqld' with the `--skip-name-resolve' option.
  21410.  
  21411.         - Start `mysqld' with the `--skip-host-cache' option.
  21412.  
  21413.         - On Unix, if you are running the server and the client on the
  21414.           same machine, connect to `localhost'. Unix connections to
  21415.           `localhost' use a Unix socket file rather than TCP/IP.
  21416.  
  21417.         - On Windows, if you are running the server and the client on
  21418.           the same machine and the server supports named pipe
  21419.           connections, connect to the hostname `.' (period).
  21420.           Connections to `.' use a named pipe rather than TCP/IP.
  21421.  
  21422.    * If `mysql -u root test' works but `mysql -h YOUR_HOSTNAME -u root
  21423.      test' results in `Access denied' (where YOUR_HOSTNAME is the
  21424.      actual hostname of the local host), you may not have the correct
  21425.      name for your host in the `user' table.  A common problem here is
  21426.      that the `Host' value in the user table entry specifies an
  21427.      unqualified hostname, but your system's name resolution routines
  21428.      return a fully qualified domain name (or vice versa).  For
  21429.      example, if you have an entry with host `'tcx'' in the `user'
  21430.      table, but your DNS tells MySQL that your hostname is
  21431.      `'tcx.subnet.se'', the entry will not work. Try adding an entry to
  21432.      the `user' table that contains the IP number of your host as the
  21433.      `Host' column value.  (Alternatively, you could add an entry to the
  21434.      `user' table with a `Host' value that contains a wildcard; for
  21435.      example, `'tcx.%''.  However, use of hostnames ending with `%' is
  21436.      _insecure_ and is _not_ recommended!)
  21437.  
  21438.    * If `mysql -u USER_NAME test' works but `mysql -u USER_NAME
  21439.      OTHER_DB_NAME' does not, you have not granted database access for
  21440.      OTHER_DB_NAME to the given user.
  21441.  
  21442.    * If `mysql -u USER_NAME' works when executed on the server host, but
  21443.      `mysql -h HOST_NAME -u USER_NAME' doesn't work when executed on a
  21444.      remote client host, you have not enabled access to the server for
  21445.      the given username from the remote host.
  21446.  
  21447.    * If you can't figure out why you get `Access denied', remove from
  21448.      the `user' table all entries that have `Host' values containing
  21449.      wildcards (entries that contain `%' or `_').  A very common error
  21450.      is to insert a new entry with `Host'=`'%'' and
  21451.      `User'=`'SOME_USER'', thinking that this will allow you to specify
  21452.      `localhost' to connect from the same machine.  The reason that this
  21453.      doesn't work is that the default privileges include an entry with
  21454.      `Host'=`'localhost'' and `User'=`'''.  Because that entry has a
  21455.      `Host' value `'localhost'' that is more specific than `'%'', it is
  21456.      used in preference to the new entry when connecting from
  21457.      `localhost'!  The correct procedure is to insert a second entry
  21458.      with `Host'=`'localhost'' and `User'=`'SOME_USER'', or to delete
  21459.      the entry with `Host'=`'localhost'' and `User'=`'''.  After
  21460.      deleting the entry, remember to issue a `FLUSH PRIVILEGES'
  21461.      statement to reload the grant tables.
  21462.  
  21463.    * If you get the following error, you may have a problem with the
  21464.      `db' or `host' table:
  21465.  
  21466.           Access to database denied
  21467.  
  21468.      If the entry selected from the `db' table has an empty value in the
  21469.      `Host' column, make sure that there are one or more corresponding
  21470.      entries in the `host' table specifying which hosts the `db' table
  21471.      entry applies to.
  21472.  
  21473.    * If you are able to connect to the MySQL server, but get an `Access
  21474.      denied' message whenever you issue a `SELECT ...  INTO OUTFILE' or
  21475.      `LOAD DATA INFILE' statement, your entry in the `user' table
  21476.      doesn't have the `FILE' privilege enabled.
  21477.  
  21478.    * If you change the grant tables directly (for example, by using
  21479.      `INSERT', `UPDATE', or `DELETE' statements) and your changes seem
  21480.      to be ignored, remember that you must execute a `FLUSH PRIVILEGES'
  21481.      statement or a `mysqladmin flush-privileges' command to cause the
  21482.      server to re-read the privilege tables. Otherwise, your changes
  21483.      have no effect until the next time the server is restarted.
  21484.      Remember that after you change the `root' password with an
  21485.      `UPDATE' command, you won't need to specify the new password until
  21486.      after you flush the privileges, because the server won't know
  21487.      you've changed the password yet!
  21488.  
  21489.    * If your privileges seem to have changed in the middle of a
  21490.      session, it may be that a MySQL administrator has changed them.
  21491.      Reloading the grant tables affects new client connections, but it
  21492.      also affects existing connections as indicated in *Note Privilege
  21493.      changes::.
  21494.  
  21495.    * If you have access problems with a Perl, PHP, Python, or ODBC
  21496.      program, try to connect to the server with `mysql -u USER_NAME
  21497.      DB_NAME' or `mysql -u USER_NAME -pYOUR_PASS DB_NAME'.  If you are
  21498.      able to connect using the `mysql' client, the problem lies with
  21499.      your program, not with the access privileges.  (There is no space
  21500.      between `-p' and the password; you can also use the
  21501.      `--password=YOUR_PASS' syntax to specify the password. If you use
  21502.      the `-p' option alone, MySQL will prompt you for the password.)
  21503.  
  21504.    * For testing, start the `mysqld' server with the
  21505.      `--skip-grant-tables' option.  Then you can change the MySQL grant
  21506.      tables and use the `mysqlaccess' script to check whether your
  21507.      modifications have the desired effect.  When you are satisfied
  21508.      with your changes, execute `mysqladmin flush-privileges' to tell
  21509.      the `mysqld' server to start using the new grant tables.
  21510.      (Reloading the grant tables overrides the `--skip-grant-tables'
  21511.      option.  This allows you to tell the server to begin using the
  21512.      grant tables again without stopping and restarting it.)
  21513.  
  21514.    * If everything else fails, start the `mysqld' server with a
  21515.      debugging option (for example, `--debug=d,general,query'). This
  21516.      will print host and user information about attempted connections,
  21517.      as well as information about each command issued. *Note Making
  21518.      trace files::.
  21519.  
  21520.    * If you have any other problems with the MySQL grant tables and
  21521.      feel you must post the problem to the mailing list, always provide
  21522.      a dump of the MySQL grant tables. You can dump the tables with the
  21523.      `mysqldump mysql' command. As always, post your problem using the
  21524.      `mysqlbug' script.  *Note Bug reports::.  In some cases, you may
  21525.      need to restart `mysqld' with `--skip-grant-tables' to run
  21526.      `mysqldump'.
  21527.  
  21528.  
  21529. Password Hashing in MySQL 4.1
  21530. -----------------------------
  21531.  
  21532. MySQL user accounts are listed in the `user' table of the `mysql'
  21533. database. Each MySQL account is assigned a password, although what is
  21534. stored in the `Password' column of the `user' table is not the
  21535. plaintext version of the password, but a hash value computed from it.
  21536. Password hash values are computed by the `PASSWORD()' function.
  21537.  
  21538. MySQL uses passwords in two phases of client/server communication:
  21539.  
  21540.    * When a client attempts to connect to the server, there is an
  21541.      initial authentication step in which the client must present a
  21542.      password that has a hash value matching the hash value stored in
  21543.      the `user' table for the account that the client wants to use.
  21544.  
  21545.    * After the client connects, it can (if it has sufficient
  21546.      privileges) set or change the password hashes for accounts listed
  21547.      in the `user' table.  The client can do this by using the
  21548.      `PASSWORD()' function to generate a password hash, or by using the
  21549.      `GRANT' or `SET PASSWORD' statements.
  21550.  
  21551.  
  21552. In other words, the server _uses_ hash values during authentication when
  21553. a client first attempts to connect. The server _generates_ hash values
  21554. if a connected client invokes the `PASSWORD()' function or uses a
  21555. `GRANT' or `SET PASSWORD' statement to set or change a password.
  21556.  
  21557. The password hashing mechanism was updated in MySQL 4.1 to provide
  21558. better security and to reduce the risk of passwords being intercepted.
  21559. However, this new mechanism is understood only by the 4.1 server and
  21560. 4.1 clients, which can result in some compatibility problems.  A 4.1
  21561. client can connect to a pre-4.1 server, because the client understands
  21562. both the old and new password hashing mechanisms. However, a pre-4.1
  21563. client that attempts to connect to a 4.1 server may run into
  21564. difficulties.  For example, a 4.0 `mysql' client that attempts to
  21565. connect to a 4.1 server may fail with the following error message:
  21566.  
  21567.      shell> mysql -h localhost -u root
  21568.      Client does not support authentication protocol requested
  21569.      by server; consider upgrading MySQL client
  21570.  
  21571. The following discussion describes the differences between the old and
  21572. new password mechanisms, and what you should do if you upgrade your
  21573. server to 4.1 but need to maintain backward compatibility with pre-4.1
  21574. clients. Additional information can be found in *Note Old client::.
  21575.  
  21576. *Note*: This discussion contrasts 4.1 behavior with pre-4.1 behavior,
  21577. but the 4.1 behavior described here actually begins with 4.1.1. MySQL
  21578. 4.1.0 is an "odd" release because it has a slightly different mechanism
  21579. than that implemented in 4.1.1 and up.  Differences between 4.1.0 and
  21580. more recent versions are described further in *Note Password hashing
  21581. 4.1.0::.
  21582.  
  21583. Prior to MySQL 4.1, password hashes computed by the `PASSWORD()'
  21584. function are 16 bytes long.  Such hashes look like this:
  21585.  
  21586.      mysql> SELECT PASSWORD('mypass');
  21587.      +--------------------+
  21588.      | PASSWORD('mypass') |
  21589.      +--------------------+
  21590.      | 6f8c114b58f2ce9e   |
  21591.      +--------------------+
  21592.  
  21593. The `Password' column of the `user' table (in which these hashes are
  21594. stored) also is 16 bytes long before MySQL 4.1.
  21595.  
  21596. As of MySQL 4.1, the `PASSWORD()' function has been modified to produce
  21597. a longer 41-byte hash value:
  21598.  
  21599.      mysql> SELECT PASSWORD('mypass');
  21600.      +-----------------------------------------------+
  21601.      | PASSWORD('mypass')                            |
  21602.      +-----------------------------------------------+
  21603.      | *43c8aa34cdc98eddd3de1fe9a9c2c2a9f92bb2098d75 |
  21604.      +-----------------------------------------------+
  21605.  
  21606. Accordingly, the `Password' column in the `user' table also must be 41
  21607. bytes long to store these values:
  21608.  
  21609.    * If you perform a new installation of MySQL 4.1, the `Password'
  21610.      column will be made 41 bytes long automatically.
  21611.  
  21612.    * If you upgrade an older installation to 4.1, you should run the
  21613.      `mysql_fix_privilege_tables' script to increase the length of the
  21614.      `Password' column from 16 to 41 bytes. (The script does not change
  21615.      existing password values, which remain 16 bytes long.)
  21616.  
  21617.  
  21618. A widened `Password' column can store password hashes in both the old
  21619. and new formats. The format of any given password hash value can be
  21620. determined two ways:
  21621.  
  21622.    * The obvious difference is the length (16 bytes versus 41 bytes).
  21623.  
  21624.    * A second difference is that password hashes in the new format
  21625.      always begin with a `*' character, whereas passwords in the old
  21626.      format never do.
  21627.  
  21628.  
  21629. The longer password hash format has better cryptographic properties, and
  21630. client authentication based on long hashes is more secure than that
  21631. based on the older short hashes.
  21632.  
  21633. The differences between short and long password hashes are relevant
  21634. both for how the server uses passwords during authentication and for
  21635. how it generates password hashes for connected clients that perform
  21636. password-changing operations.
  21637.  
  21638. The way in which the server uses password hashes during authentication
  21639. is affected by the width of the `Password' column:
  21640.  
  21641.    * If the column is short, only short-hash authentication is used.
  21642.  
  21643.    * If the column is long, it can hold either short or long hashes, and
  21644.      the server can use either format:
  21645.  
  21646.         - Pre-4.1 clients can connect, although because they know only
  21647.           about the old hashing mechanism, they can authenticate only
  21648.           for accounts that have short hashes.
  21649.  
  21650.         - 4.1 clients can authenticate for accounts that have short or
  21651.           long hashes.
  21652.  
  21653.  
  21654.  
  21655. For short-hash accounts, the authentication process is actually a bit
  21656. more secure for 4.1 clients than for older clients.  In terms of
  21657. security, the gradient from least to most secure is:
  21658.  
  21659.    * Pre-4.1 client authenticating for account with short password hash
  21660.  
  21661.    * 4.1 client authenticating for account with short password hash
  21662.  
  21663.    * 4.1 client authenticating for account with long password hash
  21664.  
  21665.  
  21666. The way in which the server generates password hashes for connected
  21667. clients is affected by the width of the `Password' column and by the
  21668. `--old-passwords' option.  A 4.1 server generates long hashes only if
  21669. certain conditions are met: The `Password' column must be wide enough
  21670. to hold long values and the `--old-passwords' option must not be given.
  21671. These conditions apply as follows:
  21672.  
  21673.    * The `Password' column must be wide enough to hold long hashes (41
  21674.      bytes).  If the column has not been updated and still has the
  21675.      pre-4.1 width of 16 bytes, the server notices that long hashes
  21676.      cannot fit into it and generates only short hashes when a client
  21677.      performs password-changing operations using `PASSWORD()', `GRANT',
  21678.      or `SET PASSWORD'.  This is the behavior that occurs if you have
  21679.      upgraded to 4.1 but have not yet run the
  21680.      `mysql_fix_privilege_tables' script to widen the `Password' column.
  21681.  
  21682.    * If the `Password' column is wide, it can store either short or long
  21683.      password hashes. In this case, `PASSWORD()', `GRANT', and `SET
  21684.      PASSWORD' generate long hashes unless the server was started with
  21685.      the `--old-passwords' option. That option forces the server to
  21686.      generate short password hashes instead.
  21687.  
  21688.  
  21689. The purpose of the `--old-passwords' option is to allow you to maintain
  21690. backward compatibility with pre-4.1 clients under circumstances where
  21691. the server would otherwise generate long password hashes. The option
  21692. doesn't affect authentication (4.1 clients can still use accounts that
  21693. have long password hashes), but it does prevent creation of a long
  21694. password hash in the `user' table as the result of a password-changing
  21695. operation. Were that to occur, the account no longer could be used by
  21696. pre-4.1 clients. Without the `--old-passwords' option, the following
  21697. undesirable scenario is possible:
  21698.  
  21699.    * An old client connects to an account that has a short password
  21700.      hash.
  21701.  
  21702.    * The client changes its own password. Without `--old-passwords',
  21703.      this results in the account having a long password hash.
  21704.  
  21705.    * The next time the old client attempts to connect to the account,
  21706.      it cannot, because the account now has a long password hash that
  21707.      requires the new hashing mechanism during authentication. (Once an
  21708.      account has a long password hash in the user table, only 4.1
  21709.      clients can authenticate for it, because pre-4.1 clients do not
  21710.      understand long hashes.)
  21711.  
  21712.  
  21713. This scenario illustrates that, if you must support older pre-4.1
  21714. clients, it is dangerous to run a 4.1 server without using the
  21715. `--old-passwords' option.  By running the server with
  21716. `--old-passwords', password-changing operations will not generate long
  21717. password hashes and thus do not cause accounts to become inaccessible
  21718. to older clients. (Those clients cannot inadvertently lock themselves
  21719. out by changing their password and ending up with a long password hash.)
  21720.  
  21721. The downside of the `--old-passwords' option is that any passwords you
  21722. create or change will use short hashes, even for 4.1 clients. Thus, you
  21723. lose the additional security provided by long password hashes. If you
  21724. want to create an account that has a long hash (for example, for use by
  21725. 4.1 clients), you must do so while running the server without
  21726. `--old-passwords'.
  21727.  
  21728. The following scenarios are possible for running a 4.1 server:
  21729.  
  21730. *Scenario 1:* Short `Password' column in user table:
  21731.  
  21732.    * Only short hashes can be stored in the `Password' column.
  21733.  
  21734.    * The server uses only short hashes during client authentication.
  21735.  
  21736.    * For connected clients, password hash-generating operations
  21737.      involving `PASSWORD()', `GRANT', or `SET PASSWORD' use short hashes
  21738.      exclusively.  Any change to an account's password results in that
  21739.      account having a short password hash.
  21740.  
  21741.    * The `--old-passwords' option can be used but is superfluous because
  21742.      with a short `Password' column, the server will generate only short
  21743.      password hashes anyway.
  21744.  
  21745.  
  21746. *Scenario 2:* Long `Password' column; server not started with
  21747. `--old-passwords' option:
  21748.  
  21749.    * Short or long hashes can be stored in the `Password' column.
  21750.  
  21751.    * 4.1 clients can authenticate for accounts that have short or long
  21752.      hashes.
  21753.  
  21754.    * Pre-4.1 clients can authenticate only for accounts that have short
  21755.      hashes.
  21756.  
  21757.    * For connected clients, password hash-generating operations
  21758.      involving `PASSWORD()', `GRANT', or `SET PASSWORD' use long hashes
  21759.      exclusively.  A change to an account's password results in that
  21760.      account having a long password hash.
  21761.  
  21762.  
  21763. As indicated earlier, a danger in this scenario is that it is possible
  21764. for accounts that have a short password hash to become inaccessible to
  21765. pre-4.1 clients. A change to such an account's password made via
  21766. `GRANT', `PASSWORD()', or `SET PASSWORD' results in the account being
  21767. given a long password hash. From that point on, no pre-4.1 client can
  21768. authenticate to that account until the client upgrades to 4.1.
  21769.  
  21770. To deal with this problem, you can change a password in a special way.
  21771. For example, normally you use `SET PASSWORD' as follows to change an
  21772. account password:
  21773.  
  21774.      mysql> SET PASSWORD FOR 'SOME_USER'@'SOME_HOST' = PASSWORD('mypass');
  21775.  
  21776. To change the password but create a short hash, use the
  21777. `OLD_PASSWORD()' function instead:
  21778.  
  21779.      mysql> SET PASSWORD FOR 'SOME_USER'@'SOME_HOST' = OLD_PASSWORD('mypass');
  21780.  
  21781. `OLD_PASSWORD()' is useful for situations in which you explicitly want
  21782. to generate a short hash.
  21783.  
  21784. *Scenario 3:* Long `Password' column; server started with
  21785. `--old-passwords' option:
  21786.  
  21787.    * Short or long hashes can be stored in the `Password' column.
  21788.  
  21789.    * 4.1 clients can authenticate for accounts that have short or long
  21790.      hashes (but note that it is possible to create long hashes only
  21791.      when the server is started without `--old-passwords').
  21792.  
  21793.    * Pre-4.1 clients can authenticate only for accounts that have short
  21794.      hashes.
  21795.  
  21796.    * For connected clients, password hash-generating operations
  21797.      involving `PASSWORD()', `GRANT', or `SET PASSWORD' use short hashes
  21798.      exclusively.  Any change to an account's password results in that
  21799.      account having a short password hash.
  21800.  
  21801.  
  21802. In this scenario, you cannot create accounts that have long password
  21803. hashes, because the `--old-passwords' option prevents generation of
  21804. long hashes.  Also, if you create an account with a long hash before
  21805. using the `--old-passwords' option, changing the account's password
  21806. while `--old-passwords' is in effect results in the account being given
  21807. a short password, causing it to lose the security benefits of a longer
  21808. hash.
  21809.  
  21810. The disadvantages for these scenarios may be summarized as follows:
  21811.  
  21812. In scenario 1, you cannot take advantage of longer hashes that provide
  21813. more secure authentication.
  21814.  
  21815. In scenario 2, accounts with short hashes become inaccessible to pre-4.1
  21816. clients if you change their passwords without explicitly using
  21817. `OLD_PASSWORD()'.
  21818.  
  21819. In scenario 3, `--old-passwords' prevents accounts with short hashes
  21820. from becoming inaccessible, but password-changing operations cause
  21821. accounts with long hashes to revert to short hashes, and you cannot
  21822. change them back to long hashes while `--old-passwords' is in effect.
  21823.  
  21824. Implications of Password Hashing Changes for Application Programs
  21825. .................................................................
  21826.  
  21827. An upgrade to MySQL 4.1 can cause a compatibility issue for
  21828. applications that use `PASSWORD()' to generate passwords for their own
  21829. purposes. Applications really should not do this, because `PASSWORD()'
  21830. should be used only to manage passwords for MySQL accounts. But some
  21831. applications use `PASSWORD()' for their own purposes anyway.
  21832.  
  21833. If you upgrade to 4.1 and run the server under conditions where it
  21834. generates long password hashes, an application that uses `PASSWORD()'
  21835. for its own passwords will break.  The recommended course of action is
  21836. to modify the application to use another function, such as `SHA1()' or
  21837. `MD5()', to produce hashed values.  If that is not possible, you can
  21838. use the `OLD_PASSWORD()' function, which is provided to generate short
  21839. hashes in the old format. But note that `OLD_PASSWORD()' may one day no
  21840. longer be supported.
  21841.  
  21842. If the server is running under circumstances where it generates short
  21843. hashes, `OLD_PASSWORD()' is available but is equivalent to `PASSWORD()'.
  21844.  
  21845. Password Hashing in MySQL 4.1.0
  21846. ...............................
  21847.  
  21848. Password hashing in MySQL 4.1.0 differs from hashing in 4.1.1 and up.
  21849. The 4.1.0 differences are:
  21850.  
  21851.    * Password hashes are 45 bytes long rather than 41 bytes.
  21852.  
  21853.    * The `PASSWORD()' function is non-repeatable.  That is, with a given
  21854.      argument X, successive calls to `PASSWORD(X)' generate different
  21855.      results.
  21856.  
  21857.  
  21858. These differences make authentication in 4.1.0 incompatible with that of
  21859. releases that follow it.  If you have upgraded to MySQL 4.1.0, it is
  21860. recommended that you upgrade to a newer version as soon as possible.
  21861. After you do, reassign any long passwords in the `user' table so that
  21862. they are compatible with the 41-byte format.
  21863.  
  21864. MySQL User Account Management
  21865. =============================
  21866.  
  21867. This section describes how to set up accounts for clients of your MySQL
  21868. server. It discusses the following topics:
  21869.  
  21870.    * The meaning of account names and passwords as used in MySQL and
  21871.      how that compares to names and passwords used by your operating
  21872.      system
  21873.  
  21874.    * How to set up new accounts and remove existing accounts
  21875.  
  21876.    * How to change passwords
  21877.  
  21878.    * Guidelines for using passwords securely
  21879.  
  21880.    * How to use secure connections with SSL
  21881.  
  21882.  
  21883. MySQL Usernames and Passwords
  21884. -----------------------------
  21885.  
  21886. A MySQL account is defined in terms of a username and the client host
  21887. or hosts from which the user can connect to the server. The account
  21888. also has a password.  There are several distinctions between the way
  21889. usernames and passwords are used by MySQL and the way they are used by
  21890. your operating system:
  21891.  
  21892.    * Usernames, as used by MySQL for authentication purposes, have
  21893.      nothing to do with usernames (login names) as used by Windows or
  21894.      Unix.  On Unix, most MySQL clients by default try to log in using
  21895.      the current Unix username as the MySQL username, but that is for
  21896.      convenience only. The default can be overridden easily, because
  21897.      client programs allow any username to be specified with a `-u' or
  21898.      `--user' option. Because this means that anyone can attempt to
  21899.      connect to the server using any username, you can't make a
  21900.      database secure in any way unless all MySQL accounts have
  21901.      passwords.  Anyone who specifies a username for an account that
  21902.      has no password will be able to connect successfully to the server.
  21903.  
  21904.    * MySQL usernames can be up to 16 characters long. Operating system
  21905.      usernames might have a different maximum length. For example, Unix
  21906.      usernames typically are limited to eight characters.
  21907.  
  21908.    * MySQL passwords have nothing to do with passwords for logging in
  21909.      to your operating system.  There is no necessary connection
  21910.      between the password you use to log in to a Windows or Unix
  21911.      machine and the password you use to access the MySQL server on
  21912.      that machine.
  21913.  
  21914.    * MySQL encrypts passwords using its own algorithm. This encryption
  21915.      is different from that used during the Unix login process.  MySQL
  21916.      password encryption is the same as that implemented by the
  21917.      `PASSWORD()' SQL function.  Unix password encryption is the same
  21918.      as that implemented by the `ENCRYPT()' SQL function.  See the
  21919.      descriptions of the `PASSWORD()' and `ENCRYPT()' functions in
  21920.      *Note Encryption functions::.  From version 4.1 on, MySQL employs
  21921.      a stronger authentication method that has better password
  21922.      protection during the connection process than in earlier versions.
  21923.      It is secure even if TCP/IP packets are sniffed or the `mysql'
  21924.      database is captured.  (In earlier versions, even though passwords
  21925.      are stored in encrypted form in the `user' table, knowledge of the
  21926.      encrypted password value could be used to connect to the MySQL
  21927.      server.)
  21928.  
  21929.  
  21930. When you install MySQL, the grant tables are populated with an initial
  21931. set of accounts. These accounts have names and access privileges that
  21932. are described in *Note Default privileges::, which also discusses how
  21933. to assign passwords to them.  Thereafter, you normally set up, modify,
  21934. and remove MySQL accounts using the `GRANT' and `REVOKE' statements.
  21935. *Note `GRANT': GRANT.
  21936.  
  21937. When you connect to a MySQL server with a command-line client, you
  21938. should specify the username and password for the account that you want
  21939. to use:
  21940.  
  21941.      shell> mysql --user=monty --password=GUESS DB_NAME
  21942.  
  21943. If you prefer short options, the command looks like this:
  21944.  
  21945.      shell> mysql -u monty -pGUESS DB_NAME
  21946.  
  21947. There must be _no space_ between the `-p' option and the following
  21948. password value.  *Note Connecting::.
  21949.  
  21950. The preceding commands include the password value on the command line,
  21951. which can be a security risk.  *Note Password security::.  To avoid
  21952. this, specify the `--password' or `-p' option without any following
  21953. password value:
  21954.  
  21955.      shell> mysql --user=monty --password DB_NAME
  21956.      shell> mysql -u monty -p DB_NAME
  21957.  
  21958. Then the client program will print a prompt and wait for you to enter
  21959. the password.  (In these examples, DB_NAME is _not_ interpreted as a
  21960. password, because it is separated from the preceding password option by
  21961. a space.)
  21962.  
  21963. On some systems, the library call that MySQL uses to prompt for a
  21964. password automatically limits the password to eight characters.  That
  21965. is a problem with the system library, not with MySQL.  Internally,
  21966. MySQL doesn't have any limit for the length of the password.  To work
  21967. around the problem, change your MySQL password to a value that is eight
  21968. or fewer characters long, or put your password in an option file.
  21969.  
  21970. Adding New User Accounts to MySQL
  21971. ---------------------------------
  21972.  
  21973. You can create MySQL accounts in two ways:
  21974.  
  21975.    * By using `GRANT' statements
  21976.  
  21977.    * By manipulating the MySQL grant tables directly
  21978.  
  21979. The preferred method is to use `GRANT' statements, because they are
  21980. more concise and less error-prone. `GRANT' is available as of MySQL
  21981. 3.22.11; its syntax is described in *Note `GRANT': GRANT.
  21982.  
  21983. Another option for creating accounts is to use one of several available
  21984. third-party programs that offer capabilities for MySQL account
  21985. administration.  `phpMyAdmin' is one such program.
  21986.  
  21987. The following examples show how to use the `mysql' client program to
  21988. set up new users.  These examples assume that privileges are set up
  21989. according to the defaults described in *Note Default privileges::.
  21990. This means that to make changes, you must connect to the MySQL server
  21991. as the MySQL `root' user, and the `root' account must have the `INSERT'
  21992. privilege for the `mysql' database and the `RELOAD' administrative
  21993. privilege.
  21994.  
  21995. First, use the `mysql' program to connect to the server as the MySQL
  21996. `root' user:
  21997.  
  21998.      shell> mysql --user=root mysql
  21999.  
  22000. If you have assigned a password to the `root' account, you'll also need
  22001. to supply a `--password' or `-p' option for this `mysql' command and
  22002. also for those later in this section.
  22003.  
  22004. After connecting to the server as `root', you can add new accounts.
  22005. The following statements use `GRANT' to set up four new accounts:
  22006.  
  22007.      mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
  22008.          ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
  22009.      mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
  22010.          ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
  22011.      mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
  22012.      mysql> GRANT USAGE ON *.* TO 'dummy'@'localhost';
  22013.  
  22014. The accounts created by these `GRANT' statements have the following
  22015. properties:
  22016.  
  22017.    * Two of the accounts have a username of `monty' and a password of
  22018.      `some_pass'. Both accounts are superuser accounts with full
  22019.      privileges to do anything. One account (`'monty'@'localhost'') can
  22020.      be used only when connecting from the local host. The other
  22021.      (`'monty'@'%'') can be used to connect from any other host.  Note
  22022.      that it is necessary to have both accounts for `monty' to be able
  22023.      to connect from anywhere as `monty'.  Without the `localhost'
  22024.      account, the anonymous-user account for `localhost' that is
  22025.      created by `mysql_install_db' would take precedence when `monty'
  22026.      connects from the local host. As a result, `monty' would be
  22027.      treated as an anonymous user.  The reason for this is that the
  22028.      anonymous-user account has a more specific `Host' column value
  22029.      than the `'monty'@'%'' account and thus comes earlier in the
  22030.      `user' table sort order.  (`user' table sorting is discussed in
  22031.      *Note Connection access::.)
  22032.  
  22033.    * One account has a username of `admin' and no password.  This
  22034.      account can be used only by connecting from the local host.  It is
  22035.      granted the `RELOAD' and `PROCESS' administrative privileges.
  22036.      These privileges allow the `admin' user to execute the `mysqladmin
  22037.      reload', `mysqladmin refresh', and `mysqladmin flush-XXX' commands,
  22038.      as well as `mysqladmin processlist' .  No privileges are granted
  22039.      for accessing any databases. You could add such privileges later
  22040.      by issuing additional `GRANT' statements.
  22041.  
  22042.    * One account has a username of `dummy' and no password.  This
  22043.      account can be used only by connecting from the local host.  No
  22044.      privileges are granted. The `USAGE' privilege in the `GRANT'
  22045.      statement allows you to create an account without giving it any
  22046.      privileges. It has the effect of setting all the global privileges
  22047.      to `'N''.  It is assumed that you will grant specific privileges
  22048.      to the account later.
  22049.  
  22050.  
  22051. As an alternative to `GRANT', you can create the same accounts directly
  22052. by issuing `INSERT' statements and then telling the server to reload
  22053. the grant tables:
  22054.  
  22055.      shell> mysql --user=root mysql
  22056.      mysql> INSERT INTO user
  22057.          ->     VALUES('localhost','monty',PASSWORD('some_pass'),
  22058.          ->     'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
  22059.      mysql> INSERT INTO user
  22060.          ->     VALUES('%','monty',PASSWORD('some_pass'),
  22061.          ->     'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
  22062.      mysql> INSERT INTO user SET Host='localhost',User='admin',
  22063.          ->     Reload_priv='Y', Process_priv='Y';
  22064.      mysql> INSERT INTO user (Host,User,Password)
  22065.          ->     VALUES('localhost','dummy','');
  22066.      mysql> FLUSH PRIVILEGES;
  22067.  
  22068. The reason for using `FLUSH PRIVILEGES' when you create accounts with
  22069. `INSERT' is to tell the server to re-read the grant tables.  Otherwise,
  22070. the changes will go unnoticed until you restart the server. With
  22071. `GRANT', `FLUSH PRIVILEGES' is unnecessary.
  22072.  
  22073. The reason for using the `PASSWORD()' function with `INSERT' is to
  22074. encrypt the password. The `GRANT' statement encrypts the password for
  22075. you, so `PASSWORD()' is unnecessary.
  22076.  
  22077. The `'Y'' values enable privileges for the accounts.  Depending on your
  22078. MySQL version, you may have to use a different number of `'Y'' values
  22079. in the first two `INSERT' statements. (Versions prior to 3.22.11 have
  22080. fewer privilege columns, and versions from 4.0.2 on have more.)  For the
  22081. `admin' account, the more readable extended `INSERT' syntax using `SET'
  22082. that is available starting with MySQL 3.22.11 is used.
  22083.  
  22084. In the `INSERT' statement for the `dummy' account, only the `Host',
  22085. `User', and `Password' columns in the `user' table record are assigned
  22086. values. None of the privilege columns are set explicitly, so MySQL
  22087. assigns them all the default value of `'N''.  This is equivalent to
  22088. what `GRANT USAGE' does.
  22089.  
  22090. Note that to set up a superuser account, it is necessary only to create
  22091. a `user' table entry with the privilege columns set to `'Y''.  `user'
  22092. table privileges are global, so no entries in any of the other grant
  22093. tables are needed.
  22094.  
  22095. The next examples create three accounts and give them access to specific
  22096. databases. Each of them has a username of `custom' and password of
  22097. `obscure'.
  22098.  
  22099. To create the accounts with `GRANT', use the following statements:
  22100.  
  22101.      shell> mysql --user=root mysql
  22102.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  22103.          ->     ON bankaccount.*
  22104.          ->     TO 'custom'@'localhost'
  22105.          ->     IDENTIFIED BY 'obscure';
  22106.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  22107.          ->     ON expenses.*
  22108.          ->     TO 'custom'@'whitehouse.gov'
  22109.          ->     IDENTIFIED BY 'obscure';
  22110.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  22111.          ->     ON customer.*
  22112.          ->     TO 'custom'@'server.domain'
  22113.          ->     IDENTIFIED BY 'obscure';
  22114.  
  22115. The three accounts can be used as follows:
  22116.  
  22117.    * The first account can access the `bankaccount' database, but only
  22118.      from the local host.
  22119.  
  22120.    * The second account can access the `expenses' database, but only
  22121.      from the host `whitehouse.gov'.
  22122.  
  22123.    * The third account can access the `customer' database, but only
  22124.      from the host `server.domain'.
  22125.  
  22126. To set up the `custom' accounts without `GRANT', use `INSERT'
  22127. statements as follows to modify the grant tables directly:
  22128.  
  22129.      shell> mysql --user=root mysql
  22130.      mysql> INSERT INTO user (Host,User,Password)
  22131.          ->     VALUES('localhost','custom',PASSWORD('obscure'));
  22132.      mysql> INSERT INTO user (Host,User,Password)
  22133.          ->     VALUES('whitehouse.gov','custom',PASSWORD('obscure'));
  22134.      mysql> INSERT INTO user (Host,User,Password)
  22135.          ->     VALUES('server.domain','custom',PASSWORD('obscure'));
  22136.      mysql> INSERT INTO db
  22137.          ->     (Host,Db,User,Select_priv,Insert_priv,
  22138.          ->     Update_priv,Delete_priv,Create_priv,Drop_priv)
  22139.          ->     VALUES('localhost','bankaccount','custom',
  22140.          ->     'Y','Y','Y','Y','Y','Y');
  22141.      mysql> INSERT INTO db
  22142.          ->     (Host,Db,User,Select_priv,Insert_priv,
  22143.          ->     Update_priv,Delete_priv,Create_priv,Drop_priv)
  22144.          ->     VALUES('whitehouse.gov','expenses','custom',
  22145.          ->     'Y','Y','Y','Y','Y','Y');
  22146.      mysql> INSERT INTO db
  22147.          ->     (Host,Db,User,Select_priv,Insert_priv,
  22148.          ->     Update_priv,Delete_priv,Create_priv,Drop_priv)
  22149.          ->     VALUES('server.domain','customer','custom',
  22150.          ->     'Y','Y','Y','Y','Y','Y');
  22151.      mysql> FLUSH PRIVILEGES;
  22152.  
  22153. The first three `INSERT' statements add `user' table entries that allow
  22154. the user `custom' to connect from the various hosts with the given
  22155. password, but grant no global privileges (all privileges are set to the
  22156. default value of `'N'').  The next three `INSERT' statements add `db'
  22157. table entries that grant privileges to `custom' for the `bankaccount',
  22158. `expenses', and `customer' databases, but only when accessed from the
  22159. proper hosts.  As usual when you modify the grant tables directly, you
  22160. tell the server to reload them with `FLUSH PRIVILEGES' so that the
  22161. privilege changes take effect.
  22162.  
  22163. If you want to give a specific user access from all machines in a given
  22164. domain (for example, `mydomain.com'), you can issue a `GRANT' statement
  22165. that uses the `%' wildcard character in the host part of the account
  22166. name:
  22167.  
  22168.      mysql> GRANT ...
  22169.          ->     ON *.*
  22170.          ->     TO 'myname'@'%.mydomain.com'
  22171.          ->     IDENTIFIED BY 'mypass';
  22172.  
  22173. To do the same thing by modifying the grant tables directly, do this:
  22174.  
  22175.      mysql> INSERT INTO user (Host,User,Password,...)
  22176.          ->     VALUES('%.mydomain.com','myname',PASSWORD('mypass'),...);
  22177.      mysql> FLUSH PRIVILEGES;
  22178.  
  22179. Removing User Accounts from MySQL
  22180. ---------------------------------
  22181.  
  22182. To remove an account, use the `DROP USER' statement, which was added in
  22183. MySQL 4.1.1.  For older versions of MySQL, use `DELETE' instead.  The
  22184. account removal procedure is described in *Note Drop user::.
  22185.  
  22186. Limiting Account Resources
  22187. --------------------------
  22188.  
  22189. Before MySQL 4.0.2, the only available method for limiting use of MySQL
  22190. server resources is to set the `max_user_connections' system variable
  22191. to a non-zero value. But that method is strictly global.  It does not
  22192. allow for management of individual accounts. Also, it limits only the
  22193. number of simultaneous connections made using a single account, not
  22194. what a client can do once connected. Both types of control are interest
  22195. to many MySQL administrators, particularly those for Internet Service
  22196. Providers.
  22197.  
  22198. Starting from MySQL 4.0.2, you can limit the following server resources
  22199. for individual accounts:
  22200.  
  22201.    * The number of queries that an account can issue per hour
  22202.  
  22203.    * The number of updates that an account can issue per hour
  22204.  
  22205.    * The number of times an account can connect to the server per hour
  22206.  
  22207. Any statement that a client can issue counts against the query limit.
  22208. Only statements that modify databases or tables count against the update
  22209. limit.
  22210.  
  22211. An account in this context is a single record in the `user' table. Each
  22212. account is uniquely identified by its `User' and `Host' column values.
  22213.  
  22214. As a prerequisite for using this feature, the `user' table in the
  22215. `mysql' database must contain the resource-related columns.  Resource
  22216. limits are stored in the `max_questions', `max_updates', and
  22217. `max_connections' columns.  If your `user' table doesn't have these
  22218. columns, it must be upgraded; see *Note Upgrading-grant-tables::.
  22219.  
  22220. To set resource limits with a `GRANT' statement, use a `WITH' clause
  22221. that names each resource to be limited and a per-hour count indicating
  22222. the limit value.  For example, to create a new account that can access
  22223. the `customer' database, but only in a limited fashion, issue this
  22224. statement:
  22225.  
  22226.      mysql> GRANT ALL ON customer.* TO 'francis'@'localhost'
  22227.          ->     IDENTIFIED BY 'frank'
  22228.          ->     WITH MAX_QUERIES_PER_HOUR 20
  22229.          ->          MAX_UPDATES_PER_HOUR 10
  22230.          ->          MAX_CONNECTIONS_PER_HOUR 5;
  22231.  
  22232. The limit types need not all be named in the `WITH' clause, but those
  22233. named can be present in any order. The value for each limit should be an
  22234. integer representing a count per hour. If the `GRANT' statement has no
  22235. `WITH' clause, the limits are each set to the default value of zero
  22236. (that is, no limit).
  22237.  
  22238. To set or change limits for an existing account, use a `GRANT USAGE'
  22239. statement at the global level (`ON *.*'). The following statement
  22240. changes the query limit for `francis' to 100:
  22241.  
  22242.      mysql> GRANT USAGE ON *.* TO 'francis'@'localhost'
  22243.          ->     WITH MAX_QUERIES_PER_HOUR 100;
  22244.  
  22245. This statement leaves the account's existing privileges unchanged and
  22246. modifies only the limit values specified.
  22247.  
  22248. To remove an existing limit, set its value to zero. For example, to
  22249. remove the limit on how many times per hour `francis' can connect, use
  22250. this statement:
  22251.  
  22252.      mysql> GRANT USAGE ON *.* TO 'francis'@'localhost'
  22253.          ->     WITH MAX_CONNECTIONS_PER_HOUR 0;
  22254.  
  22255. Resource-use counting takes place when any account has a non-zero limit
  22256. placed on its use of any of the resources.
  22257.  
  22258. As the server runs, it counts the number of times each account uses
  22259. resources.  If an account reaches its limit on number of connections
  22260. within the last hour, further connections for the account are rejected
  22261. until that hour is up. Similarly, if the account reaches its limit on
  22262. the number of queries or updates, further queries or updates are
  22263. rejected until the hour is up. In all such cases, an appropriate error
  22264. message is issued.
  22265.  
  22266. Resource counting is done per account, not per client. For example, if
  22267. your account has a query limit of 50, you cannot increase your limit to
  22268. 100 by making two simultaneous client connections to the server.
  22269. Queries issued on both connections are counted together.
  22270.  
  22271. The current resource-use counts can be reset globally for all accounts,
  22272. or individually for a given count:
  22273.  
  22274.    * To reset the current counts to zero for all accounts, issue a
  22275.      `FLUSH USER_RESOURCES' statement. The counts also can be reset by
  22276.      reloading the grant tables (for example, with a `FLUSH PRIVILEGES'
  22277.      statement or a `mysqladmin reload' command).
  22278.  
  22279.    * The counts for an individual account can be set to zero by
  22280.      re-granting it any of its limits. To do this, use `GRANT USAGE' as
  22281.      described earlier and specify a limit value equal to the value
  22282.      that the account already has.
  22283.  
  22284.  
  22285. Assigning Account Passwords
  22286. ---------------------------
  22287.  
  22288. Passwords may be assigned from the command line by using the
  22289. `mysqladmin' command:
  22290.  
  22291.      shell> mysqladmin -u USER_NAME -h HOST_NAME password "NEWPWD"
  22292.  
  22293. The account for which this command resets the password is the one with a
  22294. `user' table record that matches USER_NAME in the `User' column and the
  22295. client host _from which you connect_ in the `Host' column.
  22296.  
  22297. Another way to assign a password to an account is to issue a `SET
  22298. PASSWORD' statement:
  22299.  
  22300.      mysql> SET PASSWORD FOR 'jeffrey'@'%' = PASSWORD('biscuit');
  22301.  
  22302. Only users such as `root' with update access to the `mysql' database
  22303. can change the password for other users.  If you are not connected as
  22304. an anonymous user, you can change your own password by omitting the
  22305. `FOR' clause:
  22306.  
  22307.      mysql> SET PASSWORD = PASSWORD('biscuit');
  22308.  
  22309. You can also use a `GRANT USAGE' statement at the global level (`ON
  22310. *.*') to assign a password to an account without affecting the
  22311. account's current privileges:
  22312.  
  22313.      mysql> GRANT USAGE ON *.* TO 'jeffrey'@'%' IDENTIFIED BY 'biscuit';
  22314.  
  22315. Although it is generally preferable to assign passwords using one of the
  22316. preceding methods, you can also do so by modifying the `user' table
  22317. directly:
  22318.  
  22319.    * To establish a password when creating a new account, provide a
  22320.      value for the `Password' column:
  22321.  
  22322.           shell> mysql -u root mysql
  22323.           mysql> INSERT INTO user (Host,User,Password)
  22324.               -> VALUES('%','jeffrey',PASSWORD('biscuit'));
  22325.           mysql> FLUSH PRIVILEGES;
  22326.  
  22327.    * To change the password for an existing account, use `UPDATE' to
  22328.      set the `Password' column value:
  22329.  
  22330.           shell> mysql -u root mysql
  22331.           mysql> UPDATE user SET Password = PASSWORD('bagel')
  22332.               -> WHERE Host = '%' AND User = 'francis';
  22333.           mysql> FLUSH PRIVILEGES;
  22334.  
  22335.  
  22336. When you assign an account a password using `SET PASSWORD', `INSERT',
  22337. or `UPDATE', you must use the `PASSWORD()' function to encrypt it.
  22338. (The only exception is that you need not use `PASSWORD()' if the
  22339. password is empty.) `PASSWORD()' is necessary because the `user' table
  22340. stores passwords in encrypted form, not as plaintext.  If you forget
  22341. that fact, you are likely to set passwords like this:
  22342.  
  22343.      shell> mysql -u root mysql
  22344.      mysql> INSERT INTO user (Host,User,Password)
  22345.          -> VALUES('%','jeffrey','biscuit');
  22346.      mysql> FLUSH PRIVILEGES;
  22347.  
  22348. The result is that the literal value `'biscuit'' is stored as the
  22349. password in the `user' table, not the encrypted value.  When `jeffrey'
  22350. attempts to connect to the server using this password, the value is
  22351. encrypted and compared to the value stored in the `user' table.
  22352. However, the stored value is the literal string `'biscuit'', so the
  22353. comparison fails and the server rejects the connection:
  22354.  
  22355.      shell> mysql -u jeffrey -pbiscuit test
  22356.      Access denied
  22357.  
  22358. If you set passwords using the `GRANT ... IDENTIFIED BY' statement or
  22359. the `mysqladmin password' command, they both take care of encrypting
  22360. the password for you.  The `PASSWORD()' function is unnecessary.
  22361.  
  22362. *Note*: `PASSWORD()' encryption is different from Unix password
  22363. encryption.  *Note User names::.
  22364.  
  22365. Keeping Your Password Secure
  22366. ----------------------------
  22367.  
  22368. On an administrative level, you should never grant access to the
  22369. `mysql.user' table to any non-administrative accounts. Passwords in the
  22370. `user' table are stored in encrypted form, but in versions of MySQL
  22371. earlier than 4.1, knowing the encrypted password for an account makes it
  22372. possible to connect to the server using that account.
  22373.  
  22374. When you run a client program to connect to the MySQL server, it is
  22375. inadvisable to specify your password in a way that exposes it to
  22376. discovery by other users.  The methods you can use to specify your
  22377. password when you run client programs are listed here, along with an
  22378. assessment of the risks of each method:
  22379.  
  22380.    * Use a `-pYOUR_PASS' or `--password=YOUR_PASS' option on the command
  22381.      line.  For example:
  22382.  
  22383.           shell> mysql -u francis -pfrank DB_NAME
  22384.  
  22385.      This is convenient but insecure, because your password becomes
  22386.      visible to system status programs such as `ps' that may be invoked
  22387.      by other users to display command lines.  MySQL clients typically
  22388.      overwrite the command-line password argument with zeros during
  22389.      their initialization sequence, but there is still a brief interval
  22390.      during which the value is visible.
  22391.  
  22392.    * Use a `-p' or `--password' option with no password value
  22393.      specified.  In this case, the client program solicits the password
  22394.      from the terminal:
  22395.  
  22396.           shell> mysql -u francis -p DB_NAME
  22397.           Enter password: ********
  22398.  
  22399.      The `*' characters indicate where you enter your password. The
  22400.      password is not displayed as you enter it.
  22401.  
  22402.      It is more secure to enter your password this way than to specify
  22403.      it on the command line because it is not visible to other users.
  22404.      However, this method of entering a password is suitable only for
  22405.      programs that you run interactively.  If you want to invoke a
  22406.      client from a script that runs non-interactively, there is no
  22407.      opportunity to enter the password from the terminal. On some
  22408.      systems, you may even find that the first line of your script is
  22409.      read and interpreted (incorrectly) as your password!
  22410.  
  22411.    * Store your password in an option file.  For example, on Unix you
  22412.      can list your password in the `[client]' section of the `.my.cnf'
  22413.      file in your home directory:
  22414.  
  22415.           [client]
  22416.           password=your_pass
  22417.  
  22418.      If you store your password in `.my.cnf', the file should not be
  22419.      accessible to anyone but yourself. To ensure this, set the file
  22420.      access mode to `400' or `600'. For example:
  22421.  
  22422.           shell> chmod 600 .my.cnf
  22423.  
  22424.      *Note Option files:: discusses option files in more detail.
  22425.  
  22426.    * Store your password in the `MYSQL_PWD' environment variable.  This
  22427.      method of specifying your MySQL password must be considered
  22428.      extremely insecure and should not be used.  Some versions of `ps'
  22429.      include an option to display the environment of running processes.
  22430.      If you set `MYSQL_PWD', your password will be exposed to any other
  22431.      user who runs `ps'.  Even on systems without such a version of
  22432.      `ps', it is unwise to assume that there are no other methods by
  22433.      which users can examine process environments.  *Note Environment
  22434.      variables::.
  22435.  
  22436.  
  22437. All in all, the safest methods are to have the client program prompt
  22438. for the password or to specify the password in a properly protected
  22439. option file.
  22440.  
  22441. Using Secure Connections
  22442. ------------------------
  22443.  
  22444. Beginning with version 4.0.0, MySQL has support for secure (encrypted)
  22445. connections between MySQL clients and the server using the Secure
  22446. Sockets Layer (SSL) protocol.  This section discusses how to use SSL
  22447. connections.  It also describes a way to set up SSH on Windows.
  22448.  
  22449. The standard configuration of MySQL is intended to be as fast as
  22450. possible, so encrypted connections are not used by default.  Doing so
  22451. would make the client/server protocol much slower.  Encrypting data is
  22452. a CPU-intensive operation that requires the computer to do additional
  22453. work and can delay other MySQL tasks.  For applications that require
  22454. the security provided by encrypted connections, the extra computation
  22455. is warranted.
  22456.  
  22457. MySQL allows encryption to be enabled on a per-connection basis. You can
  22458. choose a normal unencrypted connection or a secure encrypted SSL
  22459. connection according the requirements of individual applications.
  22460.  
  22461. Basic SSL Concepts
  22462. ..................
  22463.  
  22464. To understand how MySQL uses SSL, it's necessary to explain some basic
  22465. SSL and X509 concepts. People who are already familiar with them can
  22466. skip this part.
  22467.  
  22468. By default, MySQL uses unencrypted connections between the client and
  22469. the server. This means that someone with access to the network could
  22470. watch all your traffic and look at the data being sent or received.
  22471. They could even change the data while it is in transit between client
  22472. and server. To improve security a little, you can compress
  22473. client/server traffic by using the `--compress' option when invoking
  22474. client programs.  However, this will not foil a determined attacker.
  22475.  
  22476. When you need to move information over a network in a secure fashion,
  22477. an unencrypted connection is unacceptable.  Encryption is the way to
  22478. make any kind of data unreadable. In fact, today's practice requires
  22479. many additional security elements from encryption algorithms.  They
  22480. should resist many kind of known attacks such as changing the order of
  22481. encrypted messages or replaying data twice.
  22482.  
  22483. SSL is a protocol that uses different encryption algorithms to ensure
  22484. that data received over a public network can be trusted. It has
  22485. mechanisms to detect any data change, loss, or replay. SSL also
  22486. incorporates algorithms that provide identity verification using the
  22487. X509 standard.
  22488.  
  22489. X509 makes it possible to identify someone on the Internet.  It is most
  22490. commonly used in e-commerce applications. In basic terms, there should
  22491. be some company called a "Certificate Authority" (or CA) that assigns
  22492. electronic certificates to anyone who needs them. Certificates rely on
  22493. asymmetric encryption algorithms that have two encryption keys (a
  22494. public key and a secret key). A certificate owner can show the
  22495. certificate to another party as proof of identity. A certificate
  22496. consists of its owner's public key. Any data encrypted with this public
  22497. key can be decrypted only using the corresponding secret key, which is
  22498. held by the owner of the certificate.
  22499.  
  22500. If you need more information about SSL, X509, or encryption, use your
  22501. favorite Internet search engine to search for keywords in which you are
  22502. interested.
  22503.  
  22504. Requirements
  22505. ............
  22506.  
  22507. To use SSL connections between the MySQL server and client programs,
  22508. your system must be able to support OpenSSL and your version of MySQL
  22509. must be 4.0.0 or newer.
  22510.  
  22511. To get secure connections to work with MySQL, you must do the following:
  22512.  
  22513.   1. Install the OpenSSL library. We have tested MySQL with OpenSSL
  22514.      0.9.6.  If you need OpenSSL, visit `http://www.openssl.org'.
  22515.  
  22516.   2. When you configure MySQL, run the `configure' script with the
  22517.      `--with-vio' and `--with-openssl' options.
  22518.  
  22519.   3. Make sure that you have upgraded your grant tables to include the
  22520.      SSL-related columns in the `mysql.user' table.  This is necessary
  22521.      if your grant tables date from a version prior to MySQL 4.0.0.
  22522.      The upgrade procedure is described in *Note
  22523.      Upgrading-grant-tables::.
  22524.  
  22525.   4. To check whether a running `mysqld' server supports OpenSSL,
  22526.      examine the value of the `have_openssl' system variable:
  22527.  
  22528.           mysql> SHOW VARIABLES LIKE 'have_openssl';
  22529.           +---------------+-------+
  22530.           | Variable_name | Value |
  22531.           +---------------+-------+
  22532.           | have_openssl  | YES   |
  22533.           +---------------+-------+
  22534.  
  22535.      If the value is `YES', the server supports OpenSSL connections.
  22536.  
  22537. Setting Up SSL Certificates for MySQL
  22538. .....................................
  22539.  
  22540. Here is an example for setting up SSL certificates for MySQL:
  22541.  
  22542.      DIR=`pwd`/openssl
  22543.      PRIV=$DIR/private
  22544.      
  22545.      mkdir $DIR $PRIV $DIR/newcerts
  22546.      cp /usr/share/ssl/openssl.cnf $DIR
  22547.      replace ./demoCA $DIR -- $DIR/openssl.cnf
  22548.      
  22549.      # Create necessary files: $database, $serial and $new_certs_dir
  22550.      # directory (optional)
  22551.      
  22552.      touch $DIR/index.txt
  22553.      echo "01" > $DIR/serial
  22554.      
  22555.      #
  22556.      # Generation of Certificate Authority(CA)
  22557.      #
  22558.      
  22559.      openssl req -new -x509 -keyout $PRIV/cakey.pem -out $DIR/cacert.pem \
  22560.          -config $DIR/openssl.cnf
  22561.      
  22562.      # Sample output:
  22563.      # Using configuration from /home/monty/openssl/openssl.cnf
  22564.      # Generating a 1024 bit RSA private key
  22565.      # ................++++++
  22566.      # .........++++++
  22567.      # writing new private key to '/home/monty/openssl/private/cakey.pem'
  22568.      # Enter PEM pass phrase:
  22569.      # Verifying password - Enter PEM pass phrase:
  22570.      # -----
  22571.      # You are about to be asked to enter information that will be
  22572.      # incorporated into your certificate request.
  22573.      # What you are about to enter is what is called a Distinguished Name
  22574.      # or a DN.
  22575.      # There are quite a few fields but you can leave some blank
  22576.      # For some fields there will be a default value,
  22577.      # If you enter '.', the field will be left blank.
  22578.      # -----
  22579.      # Country Name (2 letter code) [AU]:FI
  22580.      # State or Province Name (full name) [Some-State]:.
  22581.      # Locality Name (eg, city) []:
  22582.      # Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
  22583.      # Organizational Unit Name (eg, section) []:
  22584.      # Common Name (eg, YOUR name) []:MySQL admin
  22585.      # Email Address []:
  22586.      
  22587.      #
  22588.      # Create server request and key
  22589.      #
  22590.      openssl req -new -keyout $DIR/server-key.pem -out \
  22591.          $DIR/server-req.pem -days 3600 -config $DIR/openssl.cnf
  22592.      
  22593.      # Sample output:
  22594.      # Using configuration from /home/monty/openssl/openssl.cnf
  22595.      # Generating a 1024 bit RSA private key
  22596.      # ..++++++
  22597.      # ..........++++++
  22598.      # writing new private key to '/home/monty/openssl/server-key.pem'
  22599.      # Enter PEM pass phrase:
  22600.      # Verifying password - Enter PEM pass phrase:
  22601.      # -----
  22602.      # You are about to be asked to enter information that will be
  22603.      # incorporated into your certificate request.
  22604.      # What you are about to enter is what is called a Distinguished Name
  22605.      # or a DN.
  22606.      # There are quite a few fields but you can leave some blank
  22607.      # For some fields there will be a default value,
  22608.      # If you enter '.', the field will be left blank.
  22609.      # -----
  22610.      # Country Name (2 letter code) [AU]:FI
  22611.      # State or Province Name (full name) [Some-State]:.
  22612.      # Locality Name (eg, city) []:
  22613.      # Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
  22614.      # Organizational Unit Name (eg, section) []:
  22615.      # Common Name (eg, YOUR name) []:MySQL server
  22616.      # Email Address []:
  22617.      #
  22618.      # Please enter the following 'extra' attributes
  22619.      # to be sent with your certificate request
  22620.      # A challenge password []:
  22621.      # An optional company name []:
  22622.      
  22623.      #
  22624.      # Remove the passphrase from the key (optional)
  22625.      #
  22626.      
  22627.      openssl rsa -in $DIR/server-key.pem -out $DIR/server-key.pem
  22628.      
  22629.      #
  22630.      # Sign server cert
  22631.      #
  22632.      openssl ca  -policy policy_anything -out $DIR/server-cert.pem \
  22633.          -config $DIR/openssl.cnf -infiles $DIR/server-req.pem
  22634.      
  22635.      # Sample output:
  22636.      # Using configuration from /home/monty/openssl/openssl.cnf
  22637.      # Enter PEM pass phrase:
  22638.      # Check that the request matches the signature
  22639.      # Signature ok
  22640.      # The Subjects Distinguished Name is as follows
  22641.      # countryName           :PRINTABLE:'FI'
  22642.      # organizationName      :PRINTABLE:'MySQL AB'
  22643.      # commonName            :PRINTABLE:'MySQL admin'
  22644.      # Certificate is to be certified until Sep 13 14:22:46 2003 GMT
  22645.      # (365 days)
  22646.      # Sign the certificate? [y/n]:y
  22647.      #
  22648.      #
  22649.      # 1 out of 1 certificate requests certified, commit? [y/n]y
  22650.      # Write out database with 1 new entries
  22651.      # Data Base Updated
  22652.      
  22653.      #
  22654.      # Create client request and key
  22655.      #
  22656.      openssl req -new -keyout $DIR/client-key.pem -out \
  22657.          $DIR/client-req.pem -days 3600 -config $DIR/openssl.cnf
  22658.      
  22659.      # Sample output:
  22660.      # Using configuration from /home/monty/openssl/openssl.cnf
  22661.      # Generating a 1024 bit RSA private key
  22662.      # .....................................++++++
  22663.      # .............................................++++++
  22664.      # writing new private key to '/home/monty/openssl/client-key.pem'
  22665.      # Enter PEM pass phrase:
  22666.      # Verifying password - Enter PEM pass phrase:
  22667.      # -----
  22668.      # You are about to be asked to enter information that will be
  22669.      # incorporated into your certificate request.
  22670.      # What you are about to enter is what is called a Distinguished Name
  22671.      # or a DN.
  22672.      # There are quite a few fields but you can leave some blank
  22673.      # For some fields there will be a default value,
  22674.      # If you enter '.', the field will be left blank.
  22675.      # -----
  22676.      # Country Name (2 letter code) [AU]:FI
  22677.      # State or Province Name (full name) [Some-State]:.
  22678.      # Locality Name (eg, city) []:
  22679.      # Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
  22680.      # Organizational Unit Name (eg, section) []:
  22681.      # Common Name (eg, YOUR name) []:MySQL user
  22682.      # Email Address []:
  22683.      #
  22684.      # Please enter the following 'extra' attributes
  22685.      # to be sent with your certificate request
  22686.      # A challenge password []:
  22687.      # An optional company name []:
  22688.      
  22689.      #
  22690.      # Remove a passphrase from the key (optional)
  22691.      #
  22692.      openssl rsa -in $DIR/client-key.pem -out $DIR/client-key.pem
  22693.      
  22694.      #
  22695.      # Sign client cert
  22696.      #
  22697.      
  22698.      openssl ca  -policy policy_anything -out $DIR/client-cert.pem \
  22699.          -config $DIR/openssl.cnf -infiles $DIR/client-req.pem
  22700.      
  22701.      # Sample output:
  22702.      # Using configuration from /home/monty/openssl/openssl.cnf
  22703.      # Enter PEM pass phrase:
  22704.      # Check that the request matches the signature
  22705.      # Signature ok
  22706.      # The Subjects Distinguished Name is as follows
  22707.      # countryName           :PRINTABLE:'FI'
  22708.      # organizationName      :PRINTABLE:'MySQL AB'
  22709.      # commonName            :PRINTABLE:'MySQL user'
  22710.      # Certificate is to be certified until Sep 13 16:45:17 2003 GMT
  22711.      # (365 days)
  22712.      # Sign the certificate? [y/n]:y
  22713.      #
  22714.      #
  22715.      # 1 out of 1 certificate requests certified, commit? [y/n]y
  22716.      # Write out database with 1 new entries
  22717.      # Data Base Updated
  22718.      
  22719.      #
  22720.      # Create a my.cnf file that you can use to test the certificates
  22721.      #
  22722.      
  22723.      cnf=""
  22724.      cnf="$cnf [client]"
  22725.      cnf="$cnf ssl-ca=$DIR/cacert.pem"
  22726.      cnf="$cnf ssl-cert=$DIR/client-cert.pem"
  22727.      cnf="$cnf ssl-key=$DIR/client-key.pem"
  22728.      cnf="$cnf [mysqld]"
  22729.      cnf="$cnf ssl-ca=$DIR/cacert.pem"
  22730.      cnf="$cnf ssl-cert=$DIR/server-cert.pem"
  22731.      cnf="$cnf ssl-key=$DIR/server-key.pem"
  22732.      echo $cnf | replace " " '
  22733.      ' > $DIR/my.cnf
  22734.  
  22735. To test SSL connections, start the server as follows, where `$DIR' is
  22736. the pathname to the directory where the sample `my.cnf' option file is
  22737. located:
  22738.  
  22739.      shell> mysqld --defaults-file=$DIR/my.cnf &
  22740.  
  22741. Then invoke a client program using the same option file:
  22742.  
  22743.      shell> mysql --defaults-file=$DIR/my.cnf
  22744.  
  22745. If you have a MySQL source distribution, you can also test your setup by
  22746. modifying the preceding `my.cnf' file to refer to the demonstration
  22747. certificate and key files in the `SSL' directory of the distribution.
  22748.  
  22749. SSL `GRANT' Options
  22750. ...................
  22751.  
  22752. MySQL can check X509 certificate attributes in addition to the usual
  22753. authentication that is based on the username and password.  To specify
  22754. SSL-related options for a MySQL account, use the `REQUIRE' clause of
  22755. the `GRANT' statement.  *Note `GRANT': GRANT.
  22756.  
  22757. There are different possibilities for limiting connection types for an
  22758. account:
  22759.  
  22760.    * If an account has no SSL or X509 requirements, unencrypted
  22761.      connections are allowed if the username and password are valid.
  22762.      However, encrypted connections also can be used at the client's
  22763.      option, if the client has the proper certificate and key files.
  22764.  
  22765.    * `REQUIRE SSL' option limits the server to allow only SSL encrypted
  22766.      connections for the account. Note that this option can be omitted
  22767.      if there are any ACL records that allow non-SSL connections.
  22768.  
  22769.           mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22770.               -> IDENTIFIED BY 'goodsecret' REQUIRE SSL;
  22771.  
  22772.    * `REQUIRE X509' means that the client must have a valid certificate
  22773.      but that the exact certificate, issuer, and subject do not matter.
  22774.      The only requirement is that it should be possible to verify its
  22775.      signature with one of the CA certificates.
  22776.  
  22777.           mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22778.               -> IDENTIFIED BY 'goodsecret' REQUIRE X509;
  22779.  
  22780.    * `REQUIRE ISSUER 'issuer'' places the restriction on connection
  22781.      attempts that the client must present a valid X509 certificate
  22782.      issued by CA `'issuer''.  If the client presents a certificate
  22783.      that is valid but has a different issuer, the server rejects the
  22784.      connection.  Use of X509 certificates always implies encryption,
  22785.      so the `SSL' option is unneccessary.
  22786.  
  22787.           mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22788.               -> IDENTIFIED BY 'goodsecret'
  22789.               -> REQUIRE ISSUER '/C=FI/ST=Some-State/L=Helsinki/
  22790.                  O=MySQL Finland AB/CN=Tonu Samuel/Email=tonu@example.com';
  22791.  
  22792.      Note that the `ISSUER' value should be entered as a single string.
  22793.  
  22794.    * `REQUIRE SUBJECT 'subject'' places the restriction on connection
  22795.      attempts that the client must present a valid X509 certificate
  22796.      with subject `'subject'' on it.  If the client presents a
  22797.      certificate that is valid but has a different subject, the server
  22798.      rejects the connection.
  22799.  
  22800.           mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22801.               -> IDENTIFIED BY 'goodsecret'
  22802.               -> REQUIRE SUBJECT '/C=EE/ST=Some-State/L=Tallinn/
  22803.                  O=MySQL demo client certificate/
  22804.                  CN=Tonu Samuel/Email=tonu@example.com';
  22805.  
  22806.      Note that the `SUBJECT' value should be entered as a single string.
  22807.  
  22808.    * `REQUIRE CIPHER 'cipher'' is needed to ensure that strong enough
  22809.      ciphers and key lengths will be used. SSL itself can be weak if
  22810.      old algorithms with short encryption keys are used. Using this
  22811.      option, we can ask for some exact cipher method to allow a
  22812.      connection.
  22813.  
  22814.           mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22815.               -> IDENTIFIED BY 'goodsecret'
  22816.               -> REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA';
  22817.  
  22818.  
  22819. The `SUBJECT', `ISSUER', and `CIPHER' options can be combined in the
  22820. `REQUIRE' clause like this:
  22821.  
  22822.      mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22823.          -> IDENTIFIED BY 'goodsecret'
  22824.          -> REQUIRE SUBJECT '/C=EE/ST=Some-State/L=Tallinn/
  22825.             O=MySQL demo client certificate/
  22826.             CN=Tonu Samuel/Email=tonu@example.com'
  22827.          -> AND ISSUER '/C=FI/ST=Some-State/L=Helsinki/
  22828.             O=MySQL Finland AB/CN=Tonu Samuel/Email=tonu@example.com'
  22829.          -> AND CIPHER 'EDH-RSA-DES-CBC3-SHA';
  22830.  
  22831. Note that the `SUBJECT' and `ISSUER' values each should be entered as a
  22832. single string.
  22833.  
  22834. Starting from MySQL 4.0.4, the `AND' keyword is optional between
  22835. `REQUIRE' options.
  22836.  
  22837. The order of the options does not matter, but no option can be specified
  22838. twice.
  22839.  
  22840. SSL Command-Line Options
  22841. ........................
  22842.  
  22843. The following list describes options that are used for specifying the
  22844. use of SSL, certificate files, and key files.  These options are
  22845. available beginning with MySQL 4.0. They may be given on the command
  22846. line or in an option file.
  22847.  
  22848. `--ssl'
  22849.      For the server, this option specifies that the server allows SSL
  22850.      connections.  For a client program, it allows the client to
  22851.      connect to the server using SSL.  This option is not sufficient in
  22852.      itself to cause an SSL connection to be used.  You must also
  22853.      specify the `--ssl-ca', `--ssl-cert', and `--ssl-key' options.
  22854.  
  22855.      This option is more often used in its opposite form to indicate
  22856.      that SSL should _not_ be used. To do this, specify the option as
  22857.      `--skip-ssl' or `--ssl=0'.
  22858.  
  22859.      Note that use of `--ssl' doesn't _require_ an SSL connection.  For
  22860.      example, if the server or client is compiled without SSL support,
  22861.      a normal unencrypted connection will be used.
  22862.  
  22863.      The secure way to ensure that an SSL connection will be used is to
  22864.      create an account on the server that includes a `REQUIRE SSL'
  22865.      clause in the `GRANT' statement.  Then use this account to connect
  22866.      to the server, with both a server and client that have SSL support
  22867.      enabled.
  22868.  
  22869. `--ssl-ca=FILE_NAME'
  22870.      The path to a file with a list of trusted SSL CAs.
  22871.  
  22872. `--ssl-capath=DIRECTORY_NAME'
  22873.      The path to a directory that contains trusted SSL CA certificates
  22874.      in pem format.
  22875.  
  22876. `--ssl-cert=FILE_NAME'
  22877.      The name of the SSL certificate file to use for establishing a
  22878.      secure connection.
  22879.  
  22880. `--ssl-cipher=CIPHER_LIST'
  22881.      A list of allowable ciphers to use for SSL encryption.
  22882.      CIPHER_LIST has the same format as the `openssl ciphers' command.
  22883.  
  22884.      Example: `--ssl-cipher=ALL:-AES:-EXP'
  22885.  
  22886. `--ssl-key=FILE_NAME'
  22887.      The name of the SSL key file to use for establishing a secure
  22888.      connection.
  22889.  
  22890. Connecting to MySQL Remotely from Windows with SSH
  22891. ..................................................
  22892.  
  22893. Here is a note about how to connect to get a secure connection to remote
  22894. MySQL server with SSH (by David Carlson <dcarlson@mplcomm.com>):
  22895.  
  22896.   1. Install an SSH client on your Windows machine.  As a user, the
  22897.      best non-free one I've found is from `SecureCRT' from
  22898.      `http://www.vandyke.com/'.  Another option is `f-secure' from
  22899.      `http://www.f-secure.com/'. You can also find some free ones on
  22900.      `Google' at
  22901.      `http://directory.google.com/Top/Computers/Security/Products_and_Tools/Cryptography/SSH/Clients/Windows/'.
  22902.  
  22903.   2. Start your Windows SSH client.  Set `Host_Name =
  22904.      yourmysqlserver_URL_or_IP'.  Set `userid=your_userid' to log in to
  22905.      your server. This `userid' value may not be the same as the
  22906.      username of your MySQL account.
  22907.  
  22908.   3. Set up port forwarding. Either do a remote forward (Set
  22909.      `local_port: 3306', `remote_host: yourmysqlservername_or_ip',
  22910.      `remote_port: 3306' ) or a local forward (Set `port: 3306',
  22911.      `host: localhost', `remote port: 3306').
  22912.  
  22913.   4. Save everything, otherwise you'll have to redo it the next time.
  22914.  
  22915.   5. Log in to your server with the SSH session you just created.
  22916.  
  22917.   6. On your Windows machine, start some ODBC application (such as
  22918.      Access).
  22919.  
  22920.   7. Create a new file in Windows and link to MySQL using the ODBC
  22921.      driver the same way you normally do, except type in `localhost'
  22922.      for the MySQL host server, not `yourmysqlservername'.
  22923.  
  22924. You should now have an ODBC connection to MySQL, encrypted using SSH.
  22925.  
  22926. Disaster Prevention and Recovery
  22927. ================================
  22928.  
  22929. This section discusses how to make database backups and how to perform
  22930. table maintenance.  The syntax of the SQL statements described here is
  22931. given in *Note Database Administration::.  Much of the information here
  22932. pertains primarily to `MyISAM' tables.  `InnoDB' backup procedures are
  22933. given in *Note Backing up::.
  22934.  
  22935. Database Backups
  22936. ----------------
  22937.  
  22938. Because MySQL tables are stored as files, it is easy to do a backup. To
  22939. get a consistent backup, do a `LOCK TABLES' on the relevant tables,
  22940. followed by `FLUSH TABLES' for the tables.  See *Note `LOCK TABLES':
  22941. LOCK TABLES and *Note `FLUSH': FLUSH.  You need only a read lock; this
  22942. allows other clients to continue to query the tables while you are
  22943. making a copy of the files in the database directory.  The `FLUSH
  22944. TABLES' statement is needed to ensure that the all active index pages
  22945. are written to disk before you start the backup.
  22946.  
  22947. If you want to make an SQL-level backup of a table, you can use `SELECT
  22948. INTO ... OUTFILE' or `BACKUP TABLE'.  For `SELECT INTO ... OUTFILE',
  22949. the output file cannot already exist.  For `BACKUP TABLE', the same is
  22950. true as of MySQL 3.23.56 and 4.0.12, because this would be a security
  22951. risk.  See *Note `SELECT': SELECT and *Note `BACKUP TABLE': BACKUP
  22952. TABLE.
  22953.  
  22954. Another way to back up a database is to use the `mysqldump' program or
  22955. the `mysqlhotcopy script'.  See *Note `mysqldump': mysqldump and *Note
  22956. `mysqlhotcopy': mysqlhotcopy.
  22957.  
  22958.   1. Do a full backup of your database:
  22959.  
  22960.           shell> mysqldump --tab=/PATH/TO/SOME/DIR --opt DB_NAME
  22961.  
  22962.      Or:
  22963.  
  22964.           shell> mysqlhotcopy DB_NAME /PATH/TO/SOME/DIR
  22965.  
  22966.      You can also simply copy all table files (`*.frm', `*.MYD', and
  22967.      `*.MYI' files) as long as the server isn't updating anything.  The
  22968.      `mysqlhotcopy' script uses this method.  (But note that these
  22969.      methods will not work if your database contains `InnoDB' tables.
  22970.      `InnoDB' does not store table contents in database directories,
  22971.      and `mysqlhotcopy' works only for `MyISAM' and `ISAM' tables.)
  22972.  
  22973.   2. Stop `mysqld' if it's running, then start it with the
  22974.      `--log-bin[=file_name]' option.  *Note Binary log::. The binary
  22975.      log files provide you with the information you need to replicate
  22976.      changes to the database that are made subsequent to the point at
  22977.      which you executed `mysqldump'.
  22978.  
  22979. If your MySQL server is a slave replication server, then regardless of
  22980. the backup method you choose, you should also back up the `master.info'
  22981. and `relay-log.info' files when you back up your slave's data. These
  22982. files are always needed to resume replication after you restore the
  22983. slave's data. If your slave is subject to replicating `LOAD DATA
  22984. INFILE' commands, you should also back up any `SQL_LOAD-*' files that
  22985. may exist in the directory specified by the `--slave-load-tmpdir'
  22986. option. (This location defaults to the value of the `tmpdir' variable
  22987. if not specified.) The slave needs these files to resume replication of
  22988. any interrupted `LOAD DATA INFILE' operations.
  22989.  
  22990. If you have to restore `MyISAM' tables, try to recover them using
  22991. `REPAIR TABLE' or `myisamchk -r' first.  That should work in 99.9% of
  22992. all cases.  If `myisamchk' fails, try the following procedure.  Note
  22993. that it will work only if you have enabled binary logging by starting
  22994. MySQL with the `--log-bin' option; see *Note Binary log::.
  22995.  
  22996.   1. Restore the original `mysqldump' backup, or binary backup.
  22997.  
  22998.   2. Execute the following command to re-run the updates in the binary
  22999.      logs:
  23000.  
  23001.           shell> mysqlbinlog hostname-bin.[0-9]* | mysql
  23002.  
  23003.      In your case, you may want to re-run only certain binary logs, from
  23004.      certain positions (usually you want to re-run all binary logs from
  23005.      the date of the restored backup, excepting possibly some incorrect
  23006.      queries).  See *Note `mysqlbinlog': mysqlbinlog for more
  23007.      information on the `mysqlbinlog' utility and how to use it.
  23008.  
  23009.      If you are using the update logs instead, you can process their
  23010.      contents like this:
  23011.  
  23012.           shell> ls -1 -t -r hostname.[0-9]* | xargs cat | mysql
  23013.  
  23014.      `ls' is used to sort the update log filenames into the right order.
  23015.  
  23016.  
  23017. You can also do selective backups of individual files:
  23018.  
  23019.    * To dump the table, use `SELECT * INTO OUTFILE 'FILE_NAME' FROM
  23020.      TBL_NAME'.
  23021.  
  23022.    * To reload the table, use and restore with `LOAD DATA INFILE
  23023.      'file_name' REPLACE ...' To avoid duplicate records, the table
  23024.      must have a `PRIMARY KEY' or a `UNIQUE' index. The `REPLACE'
  23025.      keyword causes old records to be replaced with new ones when a new
  23026.      record duplicates an old record on a unique key value.
  23027.  
  23028.  
  23029. If you have performance problems with your server while making backups,
  23030. one strategy that can help is to set up replication and perform backups
  23031. on the slave rather than on the master.  *Note Replication Intro::.
  23032.  
  23033. If you are using a Veritas filesystem, you can make a backup like this:
  23034.  
  23035.   1. From a client program, execute `FLUSH TABLES WITH READ LOCK'.
  23036.  
  23037.   2. From another shell, execute `mount vxfs snapshot'.
  23038.  
  23039.   3. From the first client, execute `UNLOCK TABLES'.
  23040.  
  23041.   4. Copy files from the snapshot.
  23042.  
  23043.   5. Unmount the snapshot.
  23044.  
  23045. Table Maintenance and Crash Recovery
  23046. ------------------------------------
  23047.  
  23048. The following text discusses how to use `myisamchk' to check or repair
  23049. `MyISAM' tables (tables with `.MYI' and `.MYD' files).  The same
  23050. concepts apply to using `isamchk' to check or repair `ISAM' tables
  23051. (tables with `.ISM' and `.ISD' files).  *Note Storage engines::.
  23052.  
  23053. You can use the `myisamchk' utility to get information about your
  23054. database tables or to check, repair, or optimize them.  The following
  23055. sections describe how to invoke `myisamchk' (including a description of
  23056. its options), how to set up a table maintenance schedule, and how to
  23057. use `myisamchk' to perform its various functions.
  23058.  
  23059. Even though table repair with `myisamchk' is quite secure, it's always
  23060. a good idea to make a backup _before_ doing a repair (or any
  23061. maintenance operation that could make a lot of changes to a table)
  23062.  
  23063. `myisamchk' operations that affect indexes can cause `FULLTEXT' indexes
  23064. to be rebuilt with full-text parameters that are incompatible with the
  23065. values used by the MySQL server. To avoid this, read the instructions in
  23066. *Note `myisamchk' general options: myisamchk general options.
  23067.  
  23068. In many cases, you may find it simpler to do `MyISAM' table maintenance
  23069. using the SQL statements that perform operations that `myisamchk' can
  23070. do:
  23071.  
  23072.    * To check or repair `MyISAM' tables, use `CHECK TABLE' or `REPAIR
  23073.      TABLE'.
  23074.  
  23075.    * To optimize `MyISAM' tables, use `OPTIMIZE TABLE'.
  23076.  
  23077.    * To analyze `MyISAM' tables, use `ANALYZE TABLE'.
  23078.  
  23079.  
  23080. These statements were introduced in different versions, but all are
  23081. available from MySQL 3.23.14 on.  See *Note `ANALYZE TABLE': ANALYZE
  23082. TABLE, *Note `CHECK TABLE': CHECK TABLE, *Note `OPTIMIZE TABLE':
  23083. OPTIMIZE TABLE, and *Note `REPAIR TABLE': REPAIR TABLE.  The statements
  23084. can be used directly, or by means of the `mysqlcheck' client program,
  23085. which provides a command-line interface to them.
  23086.  
  23087. One advantage of these statements over `myisamchk' is that the server
  23088. does all the work. With `myisamchk', you must make sure that the server
  23089. does not use the tables at the same time. Otherwise, there can be
  23090. unwanted interaction betweeen `myisamchk' and the server.
  23091.  
  23092. `myisamchk' Invocation Syntax
  23093. .............................
  23094.  
  23095. Invoke `myisamchk' like this:
  23096.  
  23097.      shell> myisamchk [OPTIONS] TBL_NAME
  23098.  
  23099. The OPTIONS specify what you want `myisamchk' to do.  They are
  23100. described in the following sections.  You can also get a list of
  23101. options by invoking `myisamchk --help'.
  23102.  
  23103. With no options, `myisamchk' simply checks your table as the default
  23104. operation.  To get more information or to tell `myisamchk' to take
  23105. corrective action, specify options as described in the following
  23106. discussion.
  23107.  
  23108. TBL_NAME is the database table you want to check or repair.  If you run
  23109. `myisamchk' somewhere other than in the database directory, you must
  23110. specify the path to the database directory, because `myisamchk' has no
  23111. idea where the database is located.  In fact, `myisamchk' doesn't
  23112. actually care whether the files you are working on are located in a
  23113. database directory. You can copy the files that correspond to a
  23114. database table into some other location and perform recovery operations
  23115. on them there.
  23116.  
  23117. You can name several tables on the `myisamchk' command line if you
  23118. wish.  You can also specify a table by naming its index file (the file
  23119. with the `.MYI' suffix). This allows you to specify all tables in a
  23120. directory by using the pattern `*.MYI'.  For example, if you are in a
  23121. database directory, you can check all the `MyISAM' tables in that
  23122. directory like this:
  23123.  
  23124.      shell> myisamchk *.MYI
  23125.  
  23126. If you are not in the database directory, you can check all the tables
  23127. there by specifying the path to the directory:
  23128.  
  23129.      shell> myisamchk /path/to/database_dir/*.MYI
  23130.  
  23131. You can even check all tables in all databases by specifying a wildcard
  23132. with the path to the MySQL data directory:
  23133.  
  23134.      shell> myisamchk /path/to/datadir/*/*.MYI
  23135.  
  23136. The recommended way to quickly check all `MyISAM' and `ISAM' tables is:
  23137.  
  23138.      shell> myisamchk --silent --fast /path/to/datadir/*/*.MYI
  23139.      shell> isamchk --silent /path/to/datadir/*/*.ISM
  23140.  
  23141. If you want to check all `MyISAM' and `ISAM' tables and repair any that
  23142. are corrupted, you can use the following commands:
  23143.  
  23144.      shell> myisamchk --silent --force --fast --update-state \
  23145.                -O key_buffer=64M -O sort_buffer=64M \
  23146.                -O read_buffer=1M -O write_buffer=1M \
  23147.                /path/to/datadir/*/*.MYI
  23148.      shell> isamchk --silent --force -O key_buffer=64M \
  23149.                -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M \
  23150.                /path/to/datadir/*/*.ISM
  23151.  
  23152. These commands assume that you have more than 64MB free.  For more
  23153. information about memory allocation with `myisamchk', see *Note
  23154. myisamchk memory::.
  23155.  
  23156. You must ensure that no other program is using the tables while you are
  23157. running `myisamchk'.  Otherwise, when you run `myisamchk', it may
  23158. display the following error message:
  23159.  
  23160.      warning: clients are using or haven't closed the table properly
  23161.  
  23162. This means that you are trying to check a table that has been updated by
  23163. another program (such as the `mysqld' server) that hasn't yet closed
  23164. the file or that has died without closing the file properly.
  23165.  
  23166. If `mysqld' is running, you must force it to flush any table
  23167. modifications that are still buffered in memory by using `FLUSH
  23168. TABLES'. You should then ensure that no one is using the tables while
  23169. you are running `myisamchk'.  The easiest way to avoid this problem is
  23170. to use `CHECK TABLE' instead of `myisamchk' to check tables.
  23171.  
  23172. General Options for `myisamchk'
  23173. ...............................
  23174.  
  23175. The options described in this section can be used for any type of table
  23176. maintenance operation performed by `myisamchk'.  The sections following
  23177. this one describe options that pertain only to specific operations,
  23178. such as table checking or repairing.
  23179.  
  23180. `--help, -?'
  23181.      Display a help message and exit.
  23182.  
  23183. `--debug=DEBUG_OPTIONS, -# DEBUG_OPTIONS'
  23184.      Write a debugging log. The DEBUG_OPTIONS string often is
  23185.      `'d:t:o,FILE_NAME''.
  23186.  
  23187. `--silent, -s'
  23188.      Silent mode.  Write output only when errors occur. You can use `-s'
  23189.      twice (`-ss') to make `myisamchk' very silent.
  23190.  
  23191. `--verbose, -v'
  23192.      Verbose mode.  Print more information. This can be used with `-d'
  23193.      and `-e'. Use `-v' multiple times (`-vv', `-vvv') for even more
  23194.      output.
  23195.  
  23196. `--version, -V'
  23197.      Display version information and exit.
  23198.  
  23199. `--wait, -w'
  23200.      Instead of terminating with an error if the table is locked, wait
  23201.      until the table is unlocked before continuing.  Note that if you
  23202.      are running `mysqld' with the `--skip-external-locking' option,
  23203.      the table can be locked only by another `myisamchk' command.
  23204.  
  23205. You can also set the following variables by using `--VAR_NAME=VALUE'
  23206. options:
  23207.  
  23208. *Variable*                *Default Value*
  23209. `decode_bits'             9
  23210. `ft_max_word_len'         version-dependent
  23211. `ft_min_word_len'         4
  23212. `ft_stopword_file'        built-in list
  23213. `key_buffer_size'         523264
  23214. `myisam_block_size'       1024
  23215. `read_buffer_size'        262136
  23216. `sort_buffer_size'        2097144
  23217. `sort_key_blocks'         16
  23218. `write_buffer_size'       262136
  23219.  
  23220. It is also possible to set variables by using
  23221. `--set-variable=VAR_NAME=VALUE' or `-O VAR_NAME=VALUE' syntax. However,
  23222. this syntax is deprecated as of MySQL 4.0.
  23223.  
  23224. The possible `myisamchk' variables and their default values can be
  23225. examined with `myisamchk --help':
  23226.  
  23227. `sort_buffer_size' is used when the keys are repaired by sorting keys,
  23228. which is the normal case when you use `--recover'.
  23229.  
  23230. `key_buffer_size' is used when you are checking the table with
  23231. `--extend-check' or when the keys are repaired by inserting keys row by
  23232. row into the table (like when doing normal inserts). Repairing through
  23233. the key buffer is used in the following cases:
  23234.  
  23235.    * You use `--safe-recover'.
  23236.  
  23237.    * The temporary files needed to sort the keys would be more than
  23238.      twice as big as when creating the key file directly.  This is
  23239.      often the case when you have large key values for  `CHAR',
  23240.      `VARCHAR', or `TEXT' columns, because the sort operation needs to
  23241.      store the complete key values as it proceeds. If you have lots of
  23242.      temporary space and you can force `myisamchk' to repair by
  23243.      sorting, you can use the `--sort-recover' option.
  23244.  
  23245.  
  23246. Repairing through the key buffer takes much less disk space than using
  23247. sorting, but is also much slower.
  23248.  
  23249. If you want a faster repair, set the `key_buffer_size' and
  23250. `sort_buffer_size' variables to about 25% of your available memory.
  23251. You can set both variables to large values, because only one of them is
  23252. used at a time.
  23253.  
  23254. `myisam_block_size' is the size used for index blocks. It is available
  23255. as of MySQL 4.0.0.
  23256.  
  23257. The `ft_min_word_len' and `ft_max_word_len' variables are available as
  23258. of MySQL 4.0.0.  `ft_stopword_file' is available as of MySQL 4.0.19.
  23259.  
  23260. `ft_min_word_len' and `ft_max_word_len' indicate the minimum and
  23261. maximum word length for `FULLTEXT' indexes. `ft_stopword_file' names
  23262. the stopword file. These need to be set under the following
  23263. circumstances.
  23264.  
  23265. If you use `myisamchk' to perform an operation that modifies table
  23266. indexes (such as repair or analyze), the `FULLTEXT' indexes are rebuilt
  23267. using the default full-text parameter values for minimum and maximum
  23268. word length and the stopword file unless you specify otherwise.  This
  23269. can result in queries failing.
  23270.  
  23271. The problem occurs because these parameters are known only by the
  23272. server.  They are not stored in `MyISAM' index files.  To avoid the
  23273. problem if you have modified the minimum or maximum word length or the
  23274. stopword file in the server, specify the same `ft_min_word_len',
  23275. `ft_max_word_len', and `ft_stopword_file' values to `myisamchk' that
  23276. you use for `mysqld'. For example, if you have set the minimum word
  23277. length to 3, you can repair a table with `myisamchk' like this:
  23278.  
  23279.      shell> myisamchk --recover --ft_min_word_len=3 TBL_NAME.MYI
  23280.  
  23281. To ensure that `myisamchk' and the server use the same values for
  23282. full-text parameters, you can place each one in both the `[mysqld]' and
  23283. `[myisamchk]' sections of an option file:
  23284.  
  23285.      [mysqld]
  23286.      ft_min_word_len=3
  23287.      
  23288.      [myisamchk]
  23289.      ft_min_word_len=3
  23290.  
  23291. An alternative to using `myisamchk' is to use the `REPAIR TABLE',
  23292. `ANALYZE TABLE', `OPTIMIZE TABLE', or `ALTER TABLE'.  These statements
  23293. are performed by the server, which knows the proper full-text parameter
  23294. values to use.
  23295.  
  23296. Check Options for `myisamchk'
  23297. .............................
  23298.  
  23299. `myisamchk' supports the following options for table checking
  23300. operations:
  23301.  
  23302. `--check, -c'
  23303.      Check the table for errors. This is the default operation if you
  23304.      specify no option that selects an operation type explicitly.
  23305.  
  23306. `--check-only-changed, -C'
  23307.      Check only tables that have changed since the last check.
  23308.  
  23309. `--extend-check, -e'
  23310.      Check the table very thoroughly. This is quite slow if the table
  23311.      has many indexes.  This option should only be used in extreme
  23312.      cases.  Normally, `myisamchk' or `myisamchk --medium-check' should
  23313.      be able to determine whether there are any errors in the table.
  23314.  
  23315.      If you are using `--extend-check' and have plenty of memory,
  23316.      setting the `key_buffer_size' variable to a large value will help
  23317.      the repair operation run faster.
  23318.  
  23319. `--fast, -F'
  23320.      Check only tables that haven't been closed properly.
  23321.  
  23322. `--force, -f'
  23323.      Do a repair operation automatically if `myisamchk' finds any
  23324.      errors in the table.  The repair type is the same as that
  23325.      specified with the `--repair' or `-r' option.
  23326.  
  23327. `--information, -i'
  23328.      Print informational statistics about the table that is checked.
  23329.  
  23330. `--medium-check, -m'
  23331.      Do a check that is faster than an `--extend-check' operation.
  23332.      This finds only 99.99% of all errors, which should be good enough
  23333.      in most cases.
  23334.  
  23335. `--read-only, -T'
  23336.      Don't mark the table as checked. This is useful if you use
  23337.      `myisamchk' to check a table that is in use by some other
  23338.      application that doesn't use locking, such as `mysqld' when run
  23339.      with the `--skip-external-locking' option.
  23340.  
  23341. `--update-state, -U'
  23342.      Store information in the `.MYI' file to indicate when the table was
  23343.      checked and whether the table crashed.  This should be used to get
  23344.      full benefit of the `--check-only-changed' option, but you
  23345.      shouldn't use this option if the `mysqld' server is using the
  23346.      table and you are running it with the `--skip-external-locking'
  23347.      option.
  23348.  
  23349. Repair Options for `myisamchk'
  23350. ..............................
  23351.  
  23352. `myisamchk' supports the following options for table repair operations:
  23353.  
  23354. `--backup, -B'
  23355.      Make a backup of the `.MYD' file as `file_name-time.BAK'
  23356.  
  23357. `--character-sets-dir=PATH'
  23358.      The directory where character sets are installed.  *Note Character
  23359.      sets::.
  23360.  
  23361. `--correct-checksum'
  23362.      Correct the checksum information for the table.
  23363.  
  23364. `--data-file-length=#, -D #'
  23365.      Maximum length of the data file (when re-creating data file when
  23366.      it's "full").
  23367.  
  23368. `--extend-check, -e'
  23369.      Do a repair that tries to to recover every possible row from the
  23370.      data file.  Normally this will also find a lot of garbage rows.
  23371.      Don't use this option unless you are totally desperate.
  23372.  
  23373. `--force, -f'
  23374.      Overwrite old temporary files (files with names like
  23375.      `TBL_NAME.TMD') instead of aborting.
  23376.  
  23377. `--keys-used=#, -k #'
  23378.      For `myisamchk', the option value indicates which indexes to
  23379.      update.  Each binary bit of the option value corresponds to a
  23380.      table index, where the first index is bit 0.  For `isamchk', the
  23381.      option value indicates that only the first # of the table indexes
  23382.      should be updated.  In either case, an option value of 0 disables
  23383.      updates to all indexes, which can be used to get faster inserts.
  23384.      Deactivated indexes can be reactivated by using `myisamchk -r' or
  23385.      (`isamchk -r').
  23386.  
  23387. `--no-symlinks, -l'
  23388.      Do not follow symbolic links. Normally `myisamchk' repairs the
  23389.      table that a symlink points to.  This option doesn't exist as of
  23390.      MySQL 4.0, because versions from 4.0 on will not remove symlinks
  23391.      during repair operations.
  23392.  
  23393. `--parallel-recover, -p'
  23394.      Uses the same technique as `-r' and `-n', but creates all the keys
  23395.      in parallel, using different threads.  This option was added in
  23396.      MySQL 4.0.2.  _This is alpha code. Use at your own risk!_
  23397.  
  23398. `--quick, -q'
  23399.      Achieve a faster repair by not modifying the data file. You can
  23400.      specify this option twice to force `myisamchk' to modify the
  23401.      original data file in case of duplicate keys.
  23402.  
  23403. `--recover, -r'
  23404.      Do a repair that can fix almost any problem except unique keys
  23405.      that aren't unique (which is an extremely unlikely error with
  23406.      `ISAM'/`MyISAM' tables).  If you want to recover a table, this is
  23407.      the option to try first. You should try `-o' only if `myisamchk'
  23408.      reports that the table can't be recovered by `-r'.  (In the
  23409.      unlikely case that `-r' fails, the data file is still intact.)
  23410.  
  23411.      If you have lots of memory, you should increase the value of
  23412.      `sort_buffer_size'.
  23413.  
  23414. `--safe-recover, -o'
  23415.      Do a repair using an old recovery method that reads through all
  23416.      rows in order and updates all index trees based on the rows found.
  23417.      This is an order of magnitude slower than `-r', but can handle a
  23418.      couple of very unlikely cases that `-r' cannot.  This recovery
  23419.      method also uses much less disk space than `-r'. Normally, you
  23420.      should repair first with `-r', and then with `-o' only if `-r'
  23421.      fails.
  23422.  
  23423.      If you have lots of memory, you should increase the value of
  23424.      `key_buffer_size'.
  23425.  
  23426. `--set-character-set=NAME'
  23427.      Change the character set used by the table indexes.
  23428.  
  23429. `--sort-recover, -n'
  23430.      Force `myisamchk' to use sorting to resolve the keys even if the
  23431.      temporary files should be very big.
  23432.  
  23433. `--tmpdir=PATH, -t PATH'
  23434.      Path of the directory to be used for storing temporary files. If
  23435.      this is not set, `myisamchk' uses the value of the `TMPDIR'
  23436.      environment variable.  Starting from MySQL 4.1, `tmpdir' can be
  23437.      set to a list of directory paths that will be used successively in
  23438.      round-robin fashion for creating temporary files. The separator
  23439.      character between directory names should be colon (`:') on Unix
  23440.      and semicolon (`;') on Windows, NetWare, and OS/2.
  23441.  
  23442. `--unpack, -u'
  23443.      Unpack a table that was packed with `myisampack'.
  23444.  
  23445. Other Options for `myisamchk'
  23446. .............................
  23447.  
  23448. `myisamchk' supports the following options for actions other than table
  23449. checks and repairs:
  23450.  
  23451. `--analyze, -a'
  23452.      Analyze the distribution of keys. This improves join performance
  23453.      by enabling the join optimizer to better choose the order in which
  23454.      to join the tables and which keys it should use. To obtain
  23455.      information about the distribution, use a `myisamchk --description
  23456.      --verbose TBL_NAME' command or the `SHOW KEYS FROM TBL_NAME'
  23457.      statement.
  23458.  
  23459. `--description, -d'
  23460.      Print some descriptive information about the table.
  23461.  
  23462. `--set-auto-increment[=VALUE], -A[VALUE]'
  23463.      Force `AUTO_INCREMENT' numbering for new records to start at the
  23464.      given value (or higher, if there are already records with
  23465.      `AUTO_INCREMENT' values this large). If VALUE is not specified,
  23466.      `AUTO_INCREMENT' number for new records begins with the largest
  23467.      value currently in the table, plus one.
  23468.  
  23469. `--sort-index, -S'
  23470.      Sort the index tree blocks in high-low order.  This optimizes
  23471.      seeks and makes table scanning by key faster.
  23472.  
  23473. `--sort-records=#, -R #'
  23474.      Sort records according to a particular index.  This makes your
  23475.      data much more localized and may speed up range-based `SELECT' and
  23476.      `ORDER BY' operations that use this index. (The first time you use
  23477.      this option to sort a table, it may be very slow.) To determine a
  23478.      table's index numbers, use `SHOW KEYS', which displays a table's
  23479.      indexes in the same order that `myisamchk' sees them.  Indexes are
  23480.      numbered beginning with 1.
  23481.  
  23482. `myisamchk' Memory Usage
  23483. ........................
  23484.  
  23485. Memory allocation is important when you run `myisamchk'.  `myisamchk'
  23486. uses no more memory than you specify with the `-O' options.  If you are
  23487. going to use `myisamchk' on very large tables, you should first decide
  23488. how much memory you want it to use.  The default is to use only about
  23489. 3MB to perform repairs.  By using larger values, you can get
  23490. `myisamchk' to operate faster.  For example, if you have more than 32MB
  23491. RAM, you could use options such as these (in addition to any other
  23492. options you might specify):
  23493.  
  23494.      shell> myisamchk -O sort=16M -O key=16M -O read=1M -O write=1M ...
  23495.  
  23496. Using `-O sort=16M' should probably be enough for most cases.
  23497.  
  23498. Be aware that `myisamchk' uses temporary files in `TMPDIR'. If `TMPDIR'
  23499. points to a memory filesystem, you may easily get out of memory errors.
  23500. If this happens, set `TMPDIR' to point at some directory located on a
  23501. filesystem with more space and run `myisamchk' again.
  23502.  
  23503. When repairing, `myisamchk' will also need a lot of disk space:
  23504.  
  23505.    * Double the size of the data file (the original one and a copy).
  23506.      This space is not needed if you do a repair with `--quick'; in this
  23507.      case, only the index file is re-created.  This space is needed on
  23508.      the same filesystem as the original data file! (The copy is
  23509.      created in the same directory as the original.)
  23510.  
  23511.    * Space for the new index file that replaces the old one. The old
  23512.      index file is truncated at the start of the repair operation, so
  23513.      you usually ignore this space.  This space is needed on the same
  23514.      filesystem as the original index file!
  23515.  
  23516.    * When using `--recover' or `--sort-recover' (but not when using
  23517.      `--safe-recover'), you will need space for a sort buffer. The
  23518.      amount of space required is:
  23519.  
  23520.           (LARGEST_KEY + ROW_POINTER_LENGTH) * NUMBER_OF_ROWS * 2
  23521.  
  23522.      You can check the length of the keys and the `row_pointer_length'
  23523.      with `myisamchk -dv TBL_NAME'.  This space is allocated in the
  23524.      temporary directory (specified by `TMPDIR' or `--tmpdir=PATH').
  23525.  
  23526.  
  23527. If you have a problem with disk space during repair, you can try to use
  23528. `--safe-recover' instead of `--recover'.
  23529.  
  23530. Using `myisamchk' for Crash Recovery
  23531. ....................................
  23532.  
  23533. If you run `mysqld' with `--skip-external-locking' (which is the
  23534. default on some systems, such as Linux), you can't reliably use
  23535. `myisamchk' to check a table when `mysqld' is using the same table.  If
  23536. you can be sure that no one is accessing the tables through `mysqld'
  23537. while you run `myisamchk', you only have to do `mysqladmin
  23538. flush-tables' before you start checking the tables.  If you can't
  23539. guarantee this, then you must stop `mysqld' while you check the tables.
  23540. If you run `myisamchk' while `mysqld' is updating the tables, you may
  23541. get a warning that a table is corrupt even when it isn't.
  23542.  
  23543. If you are not using `--skip-external-locking', you can use `myisamchk'
  23544. to check tables at any time.  While you do this, all clients that try
  23545. to update the table will wait until `myisamchk' is ready before
  23546. continuing.
  23547.  
  23548. If you use `myisamchk' to repair or optimize tables, you _must_ always
  23549. ensure that the `mysqld' server is not using the table (this also
  23550. applies if you are using `--skip-external-locking').  If you don't take
  23551. down `mysqld', you should at least do a `mysqladmin flush-tables'
  23552. before you run `myisamchk'.  Your tables _may become corrupted_ if the
  23553. server and `myisamchk' access the tables simultaneously.
  23554.  
  23555. This section describes how to check for and deal with data corruption
  23556. in MySQL databases.  If your tables get corrupted frequently you should
  23557. try to find the reason why.  *Note Crashing::.
  23558.  
  23559. The `MyISAM' table section contains reason for why a table could be
  23560. corrupted. *Note `MyISAM' table problems: MyISAM table problems.
  23561.  
  23562. When performing crash recovery, it is important to understand that each
  23563. `MyISAM' table TBL_NAME in a database corresponds to three files in the
  23564. database directory:
  23565.  
  23566. *File*         *Purpose*
  23567. `TBL_NAME.frm' Definition (format) file
  23568. `TBL_NAME.MYD' Data file
  23569. `TBL_NAME.MYI' Index file
  23570.  
  23571. Each of these three file types is subject to corruption in various
  23572. ways, but problems occur most often in data files and index files.
  23573.  
  23574. `myisamchk' works by creating a copy of the `.MYD' data file row by
  23575. row. It ends the repair stage by removing the old `.MYD' file and
  23576. renaming the new file to the original file name.  If you use `--quick',
  23577. `myisamchk' does not create a temporary `.MYD' file, but instead
  23578. assumes that the `.MYD' file is correct and only generates a new index
  23579. file without touching the `.MYD' file. This is safe, because
  23580. `myisamchk' automatically detects whether the `.MYD' file is corrupt
  23581. and aborts the repair if it is.  You can also specify the `--quick'
  23582. option twice to `myisamchk'.  In this case, `myisamchk' does not abort
  23583. on some errors (such as duplicate-key errors) but instead tries to
  23584. resolve them by modifying the `.MYD' file. Normally the use of two
  23585. `--quick' options is useful only if you have too little free disk space
  23586. to perform a normal repair.  In this case, you should at least make a
  23587. backup before running `myisamchk'.
  23588.  
  23589. How to Check `MyISAM' Tables for Errors
  23590. .......................................
  23591.  
  23592. To check a `MyISAM' table, use the following commands:
  23593.  
  23594. `myisamchk TBL_NAME'
  23595.      This finds 99.99% of all errors. What it can't find is corruption
  23596.      that involves _only_ the data file (which is very unusual). If you
  23597.      want to check a table, you should normally run `myisamchk' without
  23598.      options or with either the `-s' or `--silent' option.
  23599.  
  23600. `myisamchk -m TBL_NAME'
  23601.      This finds 99.999% of all errors. It first checks all index
  23602.      entries for errors and then reads through all rows. It calculates
  23603.      a checksum for all keys in the rows and verifies that the checksum
  23604.      matches the checksum for the keys in the index tree.
  23605.  
  23606. `myisamchk -e TBL_NAME'
  23607.      This does a complete and thorough check of all data (`-e' means
  23608.      "extended check"). It does a check-read of every key for each row
  23609.      to verify that they indeed point to the correct row.  This may
  23610.      take a long time for a large table that has many indexes.
  23611.      Normally, `myisamchk' stops after the first error it finds. If you
  23612.      want to obtain more information, you can add the `--verbose'
  23613.      (`-v') option.  This causes `myisamchk' to keep going, up through
  23614.      a maximum of 20 errors.
  23615.  
  23616. `myisamchk -e -i TBL_NAME'
  23617.      Like the previous command, but the `-i' option tells `myisamchk' to
  23618.      print some informational statistics, too.
  23619.  
  23620. In most cases, a simple `myisamchk' with no arguments other than the
  23621. table name is sufficient to check a table.
  23622.  
  23623. How to Repair Tables
  23624. ....................
  23625.  
  23626. The discussion in this section describes how to use `myisamchk' on
  23627. `MyISAM' tables (extensions `.MYI' and `.MYD').  If you are using
  23628. `ISAM' tables (extensions `.ISM' and `.ISD'), you should use `isamchk'
  23629. instead; the concepts are similar.
  23630.  
  23631. If you are using MySQL 3.23.16 and above, you can (and should) use the
  23632. `CHECK TABLE' and `REPAIR TABLE' statements to check and repair
  23633. `MyISAM' tables.  See *Note `CHECK TABLE': CHECK TABLE and *Note
  23634. `REPAIR TABLE': REPAIR TABLE.
  23635.  
  23636. The symptoms of a corrupted table include queries that abort
  23637. unexpectedly and observable errors such as these:
  23638.  
  23639.    * `TBL_NAME.frm' is locked against change
  23640.  
  23641.    * Can't find file `TBL_NAME.MYI' (Errcode: ###)
  23642.  
  23643.    * Unexpected end of file
  23644.  
  23645.    * Record file is crashed
  23646.  
  23647.    * Got error ### from table handler
  23648.  
  23649. To get more information about the error you can run `perror' ###, where
  23650. ### is the error number. The following example shows how to use
  23651. `perror' to find the meanings for the most common error numbers that
  23652. indicate a problem with a table:
  23653.  
  23654.      shell> perror 126 127 132 134 135 136 141 144 145
  23655.      126 = Index file is crashed / Wrong file format
  23656.      127 = Record-file is crashed
  23657.      132 = Old database file
  23658.      134 = Record was already deleted (or record file crashed)
  23659.      135 = No more room in record file
  23660.      136 = No more room in index file
  23661.      141 = Duplicate unique key or constraint on write or update
  23662.      144 = Table is crashed and last repair failed
  23663.      145 = Table was marked as crashed and should be repaired
  23664.  
  23665. Note that error 135 (no more room in record file) and error 136 (no more
  23666. room in index file) are not errors that can be fixed by a simple
  23667. repair. In this case, you have to use `ALTER TABLE' to increase the
  23668. `MAX_ROWS' and `AVG_ROW_LENGTH' table option values:
  23669.  
  23670.      ALTER TABLE TBL_NAME MAX_ROWS=XXX AVG_ROW_LENGTH=YYY;
  23671.  
  23672. If you don't know the current table option values, use `SHOW CREATE
  23673. TABLE tbl_name'.
  23674.  
  23675. For the other errors, you must repair your tables. `myisamchk' can
  23676. usually detect and fix most problems that occur.
  23677.  
  23678. The repair process involves up to four stages, described here. Before
  23679. you begin, you should change location to the database directory and
  23680. check the permissions of the table files. On Unix, make sure that they
  23681. are readable by the user that `mysqld' runs as (and to you, because you
  23682. need to access the files you are checking).  If it turns out you need
  23683. to modify files, they must also be writable by you.
  23684.  
  23685. The options that you can use for table maintenance with `myisamchk' and
  23686. `isamchk' are described in several of the earlier subsections of *Note
  23687. Table maintenance::.
  23688.  
  23689. The following section is for the cases where the above command fails or
  23690. if you want to use the extended features that `myisamchk' and `isamchk'
  23691. provide.
  23692.  
  23693. If you are going to repair a table from the command line, you must first
  23694. stop the `mysqld' server. Note that when you do `mysqladmin shutdown'
  23695. on a remote server, the `mysqld' server will still be alive for a while
  23696. after `mysqladmin' returns, until all queries are stopped and all keys
  23697. have been flushed to disk.
  23698.  
  23699. *Stage 1: Checking your tables*
  23700.  
  23701. Run `myisamchk *.MYI' or `myisamchk -e *.MYI' if you have more time.
  23702. Use the `-s' (silent) option to suppress unnecessary information.
  23703.  
  23704. If the `mysqld' server is down, you should use the `--update-state'
  23705. option to tell `myisamchk' to mark the table as 'checked'.
  23706.  
  23707. You have to repair only those tables for which `myisamchk' announces an
  23708. error.  For such tables, proceed to Stage 2.
  23709.  
  23710. If you get weird errors when checking (such as `out of memory' errors),
  23711. or if `myisamchk' crashes, go to Stage 3.
  23712.  
  23713. *Stage 2: Easy safe repair*
  23714.  
  23715. Note: If you want a repair operation to go much faster, you should set
  23716. the values of the `sort_buffer_size' and `key_buffer_size' variables
  23717. each to about 25% of your available memory when running `myisamchk' or
  23718. `isamchk'.
  23719.  
  23720. First, try `myisamchk -r -q TBL_NAME' (`-r -q' means "quick recovery
  23721. mode"). This will attempt to repair the index file without touching the
  23722. data file.  If the data file contains everything that it should and the
  23723. delete links point at the correct locations within the data file, this
  23724. should work, and the table is fixed. Start repairing the next table.
  23725. Otherwise, use the following procedure:
  23726.  
  23727.   1. Make a backup of the data file before continuing.
  23728.  
  23729.   2. Use `myisamchk -r TBL_NAME' (`-r' means "recovery mode"). This will
  23730.      remove incorrect records and deleted records from the data file and
  23731.      reconstruct the index file.
  23732.  
  23733.   3. If the preceding step fails, use `myisamchk --safe-recover
  23734.      TBL_NAME'.  Safe recovery mode uses an old recovery method that
  23735.      handles a few cases that regular recovery mode doesn't (but is
  23736.      slower).
  23737.  
  23738. If you get weird errors when repairing (such as `out of memory'
  23739. errors), or if `myisamchk' crashes, go to Stage 3.
  23740.  
  23741. *Stage 3: Difficult repair*
  23742.  
  23743. You should reach this stage only if the first 16KB block in the index
  23744. file is destroyed or contains incorrect information, or if the index
  23745. file is missing.  In this case, it's necessary to create a new index
  23746. file. Do so as follows:
  23747.  
  23748.   1. Move the data file to some safe place.
  23749.  
  23750.   2. Use the table description file to create new (empty) data and
  23751.      index files:
  23752.  
  23753.           shell> mysql DB_NAME
  23754.           mysql> SET AUTOCOMMIT=1;
  23755.           mysql> TRUNCATE TABLE TBL_NAME;
  23756.           mysql> quit
  23757.  
  23758.      If your version of MySQL doesn't have `TRUNCATE TABLE', use
  23759.      `DELETE FROM TBL_NAME' instead.
  23760.  
  23761.   3. Copy the old data file back onto the newly created data file.
  23762.      (Don't just move the old file back onto the new file; you want to
  23763.      retain a copy in case something goes wrong.)
  23764.  
  23765. Go back to Stage 2.  `myisamchk -r -q' should work now.  (This shouldn't
  23766. be an endless loop.)
  23767.  
  23768. As of MySQL 4.0.2, you can also use `REPAIR TABLE TBL_NAME USE_FRM',
  23769. which performs the whole procedure automatically.
  23770.  
  23771. *Stage 4: Very difficult repair*
  23772.  
  23773. You should reach this stage only if the `.frm' description file has also
  23774. crashed. That should never happen, because the description file isn't
  23775. changed after the table is created:
  23776.  
  23777.   1. Restore the description file from a backup and go back to Stage 3.
  23778.      You can also restore the index file and go back to Stage 2.  In
  23779.      the latter case, you should start with `myisamchk -r'.
  23780.  
  23781.   2. If you don't have a backup but know exactly how the table was
  23782.      created, create a copy of the table in another database.  Remove
  23783.      the new data file, then move the `.frm' description and `.MYI'
  23784.      index files from the other database to your crashed database.
  23785.      This gives you new description and index files, but leaves the
  23786.      `.MYD' data file alone.  Go back to Stage 2 and attempt to
  23787.      reconstruct the index file.
  23788.  
  23789.  
  23790. Table Optimization
  23791. ..................
  23792.  
  23793. To coalesce fragmented records and eliminate wasted space resulting from
  23794. deleting or updating records, run `myisamchk' in recovery mode:
  23795.  
  23796.      shell> myisamchk -r TBL_NAME
  23797.  
  23798. You can optimize a table in the same way by using the SQL `OPTIMIZE
  23799. TABLE' statement.  `OPTIMIZE TABLE' does a repair of the table and a key
  23800. analysis, and also sorts the index tree to give faster key lookups.
  23801. There is also no possibility of unwanted interaction between a utility
  23802. and the server, because the server does all the work when you use
  23803. `OPTIMIZE TABLE'. *Note `OPTIMIZE TABLE': OPTIMIZE TABLE.
  23804.  
  23805. `myisamchk' also has a number of other options you can use to improve
  23806. the performance of a table:
  23807.  
  23808.    * `-S', `--sort-index'
  23809.  
  23810.    * `-R INDEX_NUM', `--sort-records=INDEX_NUM'
  23811.  
  23812.    * `-a', `--analyze'
  23813.  
  23814. For a full description of the options, see *Note myisamchk syntax::.
  23815.  
  23816. Setting Up a Table Maintenance Schedule
  23817. ---------------------------------------
  23818.  
  23819. It is a good idea to perform table checks on a regular basis rather than
  23820. waiting for problems to occur.  One way to check and repair `MyISAM'
  23821. tables is with the `CHECK TABLE' and `REPAIR TABLE' statements.  These
  23822. are available starting with MySQL 3.23.16.  See *Note `CHECK TABLE':
  23823. CHECK TABLE and *Note `REPAIR TABLE': REPAIR TABLE.
  23824.  
  23825. Another way to check tables is to use `myisamchk'.  For maintenance
  23826. purposes, you can use `myisamchk -s'.  The `-s' option (short for
  23827. `--silent') causes `myisamchk' to run in silent mode, printing messages
  23828. only when errors occur.
  23829.  
  23830. It's also a good idea to check tables when the server starts.  For
  23831. example, whenever the machine has done a restart in the middle of an
  23832. update, you usually need to check all the tables that could have been
  23833. affected. (These are "expected crashed tables.")  To check `MyISAM'
  23834. tables automatically, start the server with the `--myisam-recover'
  23835. option, available as of MySQL 3.23.25.  If your server is too old to
  23836. support this option, you could add a test to `mysqld_safe' that runs
  23837. `myisamchk' to check all tables that have been modified during the last
  23838. 24 hours if there is an old `.pid' (process ID) file left after a
  23839. restart.  (The `.pid' file is created by `mysqld' when it starts and
  23840. removed when it terminates normally.  The presence of a `.pid' file at
  23841. system startup time indicates that `mysqld' terminated abnormally.)
  23842.  
  23843. An even better test would be to check any table whose last-modified time
  23844. is more recent than that of the `.pid' file.
  23845.  
  23846. You should also check your tables regularly during normal system
  23847. operation.  At MySQL AB, we run a `cron' job to check all our important
  23848. tables once a week, using a line like this in a `crontab' file:
  23849.  
  23850.      35 0 * * 0 /path/to/myisamchk --fast --silent /path/to/datadir/*/*.MYI
  23851.  
  23852. This prints out information about crashed tables so that we can examine
  23853. and repair them when needed.
  23854.  
  23855. Because we haven't had any unexpectedly crashed tables (tables that
  23856. become corrupted for reasons other than hardware trouble) for a couple
  23857. of years now (this is really true), once a week is more than enough for
  23858. us.
  23859.  
  23860. We recommend that to start with, you execute `myisamchk -s' each night
  23861. on all tables that have been updated during the last 24 hours, until
  23862. you come to trust MySQL as much as we do.
  23863.  
  23864. Normally, MySQL tables need little maintenance.  If you are changing
  23865. `MyISAM' tables with dynamic-sized rows (tables with `VARCHAR', `BLOB',
  23866. or `TEXT' columns) or have tables with many deleted rows you may want
  23867. to defragment/reclaim space from the tables from time to time (once a
  23868. month?).
  23869.  
  23870. You can do this by using `OPTIMIZE TABLE' on the tables in question.
  23871. Or, if you can stop the `mysqld' server for a while, change location
  23872. into the data directory and use this command while the server is
  23873. stopped:
  23874.  
  23875.      shell> myisamchk -r -s --sort-index -O sort_buffer_size=16M */*.MYI
  23876.  
  23877. For `ISAM' tables, the command is similar:
  23878.  
  23879.      shell> isamchk -r -s --sort-index -O sort_buffer_size=16M */*.ISM
  23880.  
  23881. Getting Information About a Table
  23882. ---------------------------------
  23883.  
  23884. To obtain a description of a table or statistics about it, use the
  23885. commands shown here. We explain some of the information in more detail
  23886. later:
  23887.  
  23888.    * `myisamchk -d TBL_NAME'
  23889.  
  23890.      Runs `myisamchk' in "describe mode" to produce a description of
  23891.      your table. If you start the MySQL server using the
  23892.      `--skip-external-locking' option, `myisamchk' may report an error
  23893.      for a table that is updated while it runs.  However, because
  23894.      `myisamchk' doesn't change the table in describe mode, there is no
  23895.      risk of destroying data.
  23896.  
  23897.    * `myisamchk -d -v TBL_NAME'
  23898.  
  23899.      Adding `-v' runs `myisamchk' in verbose mode so that it produces
  23900.      more information about what it is doing.
  23901.  
  23902.    * `myisamchk -eis TBL_NAME'
  23903.  
  23904.      Shows only the most important information from a table. This
  23905.      operation is slow because it must read the entire table.
  23906.  
  23907.    * `myisamchk -eiv TBL_NAME'
  23908.  
  23909.      This is like `-eis', but tells you what is being done.
  23910.  
  23911.  
  23912. Sample output for some of these commands follows. They are based on a
  23913. table with these data and index file sizes:
  23914.  
  23915.      -rw-rw-r--   1 monty    tcx     317235748 Jan 12 17:30 company.MYD
  23916.      -rw-rw-r--   1 davida   tcx      96482304 Jan 12 18:35 company.MYM
  23917.  
  23918. Example of `myisamchk -d' output:
  23919.  
  23920.      MyISAM file:     company.MYI
  23921.      Record format:   Fixed length
  23922.      Data records:    1403698  Deleted blocks:         0
  23923.      Recordlength:    226
  23924.      
  23925.      table description:
  23926.      Key Start Len Index   Type
  23927.      1   2     8   unique  double
  23928.      2   15    10  multip. text packed stripped
  23929.      3   219   8   multip. double
  23930.      4   63    10  multip. text packed stripped
  23931.      5   167   2   multip. unsigned short
  23932.      6   177   4   multip. unsigned long
  23933.      7   155   4   multip. text
  23934.      8   138   4   multip. unsigned long
  23935.      9   177   4   multip. unsigned long
  23936.          193   1           text
  23937.  
  23938. Example of `myisamchk -d -v' output:
  23939.  
  23940.      MyISAM file:         company
  23941.      Record format:       Fixed length
  23942.      File-version:        1
  23943.      Creation time:       1999-10-30 12:12:51
  23944.      Recover time:        1999-10-31 19:13:01
  23945.      Status:              checked
  23946.      Data records:            1403698  Deleted blocks:              0
  23947.      Datafile parts:          1403698  Deleted data:                0
  23948.      Datafile pointer (bytes):      3  Keyfile pointer (bytes):     3
  23949.      Max datafile length:  3791650815  Max keyfile length: 4294967294
  23950.      Recordlength:                226
  23951.      
  23952.      table description:
  23953.      Key Start Len Index   Type                  Rec/key     Root Blocksize
  23954.      1   2     8   unique  double                      1 15845376      1024
  23955.      2   15    10  multip. text packed stripped        2 25062400      1024
  23956.      3   219   8   multip. double                     73 40907776      1024
  23957.      4   63    10  multip. text packed stripped        5 48097280      1024
  23958.      5   167   2   multip. unsigned short           4840 55200768      1024
  23959.      6   177   4   multip. unsigned long            1346 65145856      1024
  23960.      7   155   4   multip. text                     4995 75090944      1024
  23961.      8   138   4   multip. unsigned long              87 85036032      1024
  23962.      9   177   4   multip. unsigned long             178 96481280      1024
  23963.          193   1           text
  23964.  
  23965. Example of `myisamchk -eis' output:
  23966.  
  23967.      Checking MyISAM file: company
  23968.      Key:  1:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  23969.      Key:  2:  Keyblocks used:  98%  Packed:   50%  Max levels:  4
  23970.      Key:  3:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  23971.      Key:  4:  Keyblocks used:  99%  Packed:   60%  Max levels:  3
  23972.      Key:  5:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23973.      Key:  6:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23974.      Key:  7:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23975.      Key:  8:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23976.      Key:  9:  Keyblocks used:  98%  Packed:    0%  Max levels:  4
  23977.      Total:    Keyblocks used:  98%  Packed:   17%
  23978.      
  23979.      Records:          1403698    M.recordlength:     226
  23980.      Packed:             0%
  23981.      Recordspace used:     100%   Empty space:          0%
  23982.      Blocks/Record:   1.00
  23983.      Record blocks:    1403698    Delete blocks:        0
  23984.      Recorddata:     317235748    Deleted data:         0
  23985.      Lost space:             0    Linkdata:             0
  23986.      
  23987.      User time 1626.51, System